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
The
<var>
element doesn't seem to raise thechange
event on its own. You'll need to trigger it manually:$('#test1').text($('[name=rdoTest]:checked').val()).change();
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
The
<var>
element doesn't seem to raise thechange
event on its own. You'll need to trigger it manually:$('#test1').text($('[name=rdoTest]:checked').val()).change();
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Yes, but it doesn't raise the
change
event.change - Event reference | MDN[^]:
The change event is fired for
<input>
,<select>
, and<textarea>
elements when a change to the element's value is committed by the user.<var>
is not one of the elements that fires thechange
event.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer