Saturday, 15 August 2015

javascript - how to get the value of jquery generated radio button -



javascript - how to get the value of jquery generated radio button -

i trying value of radio button generated jquery. think there problem in phone call events. here code.

html

<div id="divoption1"></div>

jquery radio button generate

document.getelementbyid('divoption1').innerhtml = '<input id="option1" type="radio" value="1"/> '+ questions[currentquestion]['option1'];

here phone call jquery function radio button value

$("#option1").click(function (){ alert($(this).val()); })

help me figure out problem. , tell me why event not called when generate jquery html , appent webpage ?

use on() instead of click bind event dynamically generated elements. have delegate parent element document or parent element.

live demo

$(document).on("click", "#option1", function (){ alert($(this).val()); });

javascript jquery html javascript-events

No comments:

Post a Comment