Issue
I have a radio button named "Choose" with the options yes and no. If I select any one of the options and click the button labeled "clear", I need to clear the selected option, using javascript. How can I accomplish that?
Solution
You don't need to have unique id
for the elements, you can access them by their name
attribute:
If you're using name="Choose"
, then:
With recent jQuery
$('input[name=Choose]').prop('checked',false);
With old jQuery (<1.6)
$('input[name=Choose]').attr('checked',false);
or in pure JavaScript
var ele = document.getElementsByName("Choose");
for(var i=0;i<ele.length;i++)
ele[i].checked = false;
Answered By - NVRAM
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.