radio button - Change radiobutton multiple times using jQuery -
i can't seem change between radio buttons correctly using jquery. bug in jquery? example here: http://jsbin.com/yafik/1/edit
code jsbin:
<input type="radio" name="test"> <input type="radio" name="test"> <input type="radio" name="test"> <input type="radio" name="test"> <script> $("input").eq(1).attr("checked", true); $("input").eq(2).attr("checked", true); //$("input").attr("checked", false); $("input").eq(1).attr("checked", true); </script>
you can try uncomment third line: $("input").attr("checked", false);
, i'd expect reset checked attributes.
i expect set second radiobutton checked. if @ source code, both second , third radiobuttons checked.
use .prop() boolean values
$("input").eq(1).prop("checked", true); $("input").eq(2).prop("checked", true); $("input").eq(1).prop("checked", true);
Comments
Post a Comment