Reputation: 1031
I have a group of radio buttons being created while the page is loading, and I have attached a listener to them using on()
, but the when I change the selected radio button, nothing happens.
Html:
<input type="radio" name="condition" id="cond_1" value="1">
<input type="radio" name="condition" id="cond_2" value="2">
jquery:
$("input[name=condition]:radio").on("change",function(){...});
This has worked in the past, but for some reason, it doesn't appear to be working now. Any thoughts?
Upvotes: 1
Views: 2773
Reputation: 336
Bind on
to the body, or any closer ancestor element that doesn't change:
$("body").on("change", "input[name=condition]:radio", function(){...});
Upvotes: 4