Three ways to uncheck the radio of a radio box introduction

Source: Internet
Author: User

  This article relies on jquery, the first of which is implemented using jquery, and the third is based on JS and Dom, and interested friends can understand

This article provides three ways to deselect radio, as shown in the following:    This article relies on jquery, the first of which is implemented using jquery, and the third is based on JS and Dom.   Code as follows: <! DOCTYPE html>  <html>  <head>  <title> radio button uncheck three ways </title>  < Script type= "Text/javascript" src= "Http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js" >  </script >  <script type= "Text/javascript" >  $ (function () { //  var $browsers = $ ("Input[name= Browser] ";  var $cancel = $ (" #cancel ");  var $byhide = $ (" #byhide ");  var $remove = $ (" #remove "); //   $cancel. Click (function (e) { //Remove properties, both can  //$browsers. Removeattr ("checked");  $ Browsers.attr ("Checked", False); }); //  $byhide. Click (function (e) { //Switch to a hidden field, both of which can be  / /$ ("#hidebrowser"). attr ("Checked", true);  $ ("#hidebrowser"). attr ("Checked", "checked"); }); //   $remove. Click (function (e) { //Direct DOM element, remove attribute  //If you do not use jquery, you can migrate this way   var cHeckedbrowser=document.getelementsbyname ("browser"); /*  $.each (checkedbrowser, function (i,v) {  v.checked = false;  V.removeattribute ("Checked"); });  */ //  var len = checkedbrowser.length ;  var i = 0;  for (; i < Len; i++) { ///must first assign to False, then remove attributes   checkedbrowser[i].checked = false;  No properties can be removed  //checkedbrowser[i].removeattribute ("checked"); }   }); });  </ script>  </head>  <body>  <p> which browser do you like? </p>    <form>  <input style= "Display:none id=" Hidebrowser "type=" Radio "name=" Browser "value=" >  <input type= "Radio" name= "browser" value= "Internet Explorer" >internet explorer< BR/>  <input type= "Radio" name= "browser" value= "Firefox" >firefox<br/>  <input " Radio "name=" browser "value=" Netscape ">netscape<br/>  <input type=" Radio "name=" browser "value=" OperA ">opera<br/>  <br/>  <input type=" button "id=" Cancel "value=" uncheck the Way 1 "size=" >   <input type= "button" id= "Byhide" value= "uncheck Mode 2" size= ">  <input type=" button "id=" Remove " Value= "Uncheck the way 3" size= ">  </form>    </body>  </html> 
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.