开发者

JQuery delegate not working for certain inputs

I'm tring to use JQuery to automatically sum inputs in a table where rows are added dynamically. $().delegate and $().live do not seem to work if the selector contains an input with a name with [ ]. The same selector works with bind.

Here is a sample code :

<div id="area">
  <input name="x[]"/>
  <input name="x[]"/>
  <input name="x[]"/>
  <input name="x[]"/>
</div>

$("#area").delegate("input[name='x\\[\\]']", 'cha开发者_如何转开发nge', function () {
  console.log($(this).val());
});

Any suggestions on how to fix this ?

Sample code


Worked for me using this : http://jsbin.com/eyoro3/3/edit

$("#area").delegate("input[name='x\[\]']", 'change', function () {
  console.log($(this).val());
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜