-1

I have a page on which I dynamically generate a bunch of radio buttons with id's like "r_op_1" / "r_op_2" etc.

Within my document.ready jQuery block I have

$('input:radio[id^="r_op_"]').on("click", function (e) {
 alert("I'm here");   
 ....  
 });

The function never executes. The same block worked in the older versions of jQuery (1.8x) but as I upgraded jQuery I've had to use the on() function.

What am I missing? Is my selector wrong or am I supposed to use the on() in some other way?

I am clueless at this point - thank you for your help!

marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
Gerry
  • 690
  • 1
  • 9
  • 25

2 Answers2

2

Try somethign like this

$(document).on('click', 'input:radio[id^="r_op_"]', function(event) {
    alert("I'm here");  
});
David
  • 1,799
  • 17
  • 30
-2

yea i think that on() function does not support the dynamic DOM elements try to use live() instead but i think it is deprecated

merou
  • 75
  • 4