I'm trying to use jQuery to grab the value of a selected radio button. If I build a simple static page, it works fine. Simple working fiddle
However, when I build the radio list dynamically, using PapaParse to parse a simple string and jQuery to build the list, it no longer works. Dynamic not working fiddle
Here's the function I'm using:
$(document).ready(function(){
$("input:radio[name=xAxisSelector]").on("change", function() {
if (jQuery(this).is(":checked")) {
// do stuff
alert(this.checked)
alert(this.value)
}
});
});
Clearly I'm missing something, and it's probably something simple, but I'm completely stumped. What am I doing wrong?
jQuery used to have LIVE available for this, but it doesn't any longer.
change
$("input:radio[name=xAxisSelector]").on("change", function() {
to
$(document).on("change","input:radio[name=xAxisSelector]", function() {