-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
  • 732,580
  • 175
  • 1,330
  • 1,459
Gerry
  • 866
  • 2
  • 12
  • 31

2 Answers2

2

Try somethign like this

$(document).on('click', 'input:radio[id^="r_op_"]', function(event) {
    alert("I'm here");  
});
David
  • 1,829
  • 20
  • 31
-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
  • 95
  • 4