1 <Div>2Gender:<inputtype= "Radio"ID= "Radio1"name= "Rdosex"value= "Male"/>male3 <inputtype= "Radio"ID= "Radio2"name= "Rdosex"value= "female"/>female4 <inputtype= "button"ID= "BTN1"value= "click me"/><BR/>5 <inputtype= "checkbox"name= "Play"ID= "Ckb1"value= "Football"/>Football6 <inputtype= "checkbox"name= "Play"ID= "Ckb2"value= "Basketball"/>Basketball7 <inputtype= "checkbox"name= "Play"ID= "Ckb3"value= "Volleyball"/>Volleyball8 </Div>
HTML code above
JavaScript, jquery code is as follows
1$(function(){2$ ("#btn1"). Click (function(){3 //Get Radio selected value4 vartemp1=$ ("#Radio1"). Is (": Checked")? " Male ":" Female ";5 varTemp2= (radio1.checked)? " Male ":" Female ";6 vartemp3=$ (' input:radio[name= ' rdosex "]:checked '). Val ();7 8 varPlay = ""9 //gets the value checked by the checkboxTen$ ("Input[name= ' play ']"). each (function(){ One if(true==$( This). Is (": Checked")) A { -play+=$ ( This). attr (' value '); - } the }); -Alert ("Play" +play); - }); -});
View Code
JavaScript, jquery get radio, checkbox checked values