How to trigger on change on a HTML5 var tag?
-
<input id="rdo1" type="radio" name="rdoTest" value="Hello" />
<input id="rdo2" type="radio" name="rdoTest" value="World" />
Test Value$(document).ready(function () {
$('[name=rdoTest]').change(function () {
$('#test1').text($('[name=rdoTest]:checked').val());
});$('#test1').change(function () { alert($('#test1').text()); });
});
My code here but nothing happened
-
<input id="rdo1" type="radio" name="rdoTest" value="Hello" />
<input id="rdo2" type="radio" name="rdoTest" value="World" />
Test Value$(document).ready(function () {
$('[name=rdoTest]').change(function () {
$('#test1').text($('[name=rdoTest]:checked').val());
});$('#test1').change(function () { alert($('#test1').text()); });
});
My code here but nothing happened
You have already posted this in the Web Development forum: How to trigger on change on a HTML5 var tag? - Web Development Discussion Boards[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
<input id="rdo1" type="radio" name="rdoTest" value="Hello" />
<input id="rdo2" type="radio" name="rdoTest" value="World" />
Test Value$(document).ready(function () {
$('[name=rdoTest]').change(function () {
$('#test1').text($('[name=rdoTest]:checked').val());
});$('#test1').change(function () { alert($('#test1').text()); });
});
My code here but nothing happened
The second event is triggered by the radio change, you can either place the alert in it or get it to trigger the second event, e.g.
<script>
$(document).ready(function () {
$('[name=rdoTest]').change(function () {
$('#test1').text($('[name=rdoTest]:checked').val());
$("#test1").trigger("change");
//alert($('#test1').text());
});
$('#test1').change(function () {
alert($('#test1').text());
});
});
</script>Peter Leow https://www.amazon.com/author/peterleow