apl-mhd

radioButton Checked

Dec 2nd, 2018
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title></title>
  5.  
  6.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  7.  
  8. </head>
  9. <body>
  10.  
  11.     <form action="">
  12.        
  13.  
  14.       <h1>Car</h1>
  15.       <input type="radio" name="car" value="BMW" checked> Male<br>
  16.       <input type="radio" name="car" value="Ferai"> Female<br>
  17.       <input type="radio" name="car" value="Audi"> Other<br><br>
  18.      
  19.  
  20.       <h1>Motor Cycle</h1>
  21.       <input type="radio" name="motor" value="Honda" checked> Honda<br>
  22.       <input type="radio" name="motor" value="Yahama"> Yahama<br>
  23.       <input type="radio" name="motor" value="Suzuki"> Suzuki<br><br>
  24.      
  25.  
  26.       <h1>Mobile</h1>
  27.       <input type="radio" name="mobile" value="iPhone" checked> iPhone<br>
  28.       <input type="radio" name="mobile" value="Xiomi"> Xiomi<br>
  29.       <input type="radio" name="mobile" value="Samsung"> Samsung<br><br>
  30.      
  31.  
  32.     </form>
  33.  
  34.  
  35.     <script>
  36.         var x =  document.querySelectorAll('input[type="radio"][name="car"]');
  37.  
  38.  
  39.         x[1].checked=true;
  40.  
  41.         document.write(x.length);
  42.         document.write(x[0].name);
  43.     </script>
  44.  
  45. </body>
  46. </html>
RAW Paste Data