开发者

JQuery delegate not working for certain inputs

开发者 https://www.devze.com 2023-01-08 17:58 出处:网络
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 [ ].

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

精彩评论

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