select, 라디오, checkbox의value 값 및 텍스트 상자 값 가져오기

3238 단어 jquery
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title>       radio </title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script src="js/jquery-1.7.min.js" type="text/javascript"></script>
  <script type="text/javascript">
    $(function(){
	   $("#test").click(function(){
	       $(":input[type='checkbox']:checked").each(function(){  //      checkbox value 
			                     alert($(this).val());
				})	         
			    var   docTemp=document.thisform.checkbox; 
				for   (i=0;i <docTemp.length;i++){ 
				if(docTemp[i].checked){ 
				strText=docTemp[i].nextSibling.nodeValue;						//        checkbox    
				alert(strText);      
				}
			}				
				alert($(":radio:checked + span").text());								//      radio    
				alert($(":input[type='radio']:checked").val());				//      radio value 
				alert($("#select_id").val());														//         select value 
				alert($("#select_id").find("option:selected").text());		//         select    
         })
	})
  </script>
 </head>
 <body>
 <form  name="thisform" method="post">
          :    <input type="radio" name="radio1"   class="rd"   id="rd" value="1"/> 
	  <span>a</span>
        <input type="radio" name="radio1"class="rd"  id="tt" value="2" />
       <span>b</span>
        <input type="radio"name="radio1"class="rd"  value="3"/>
       <span>c</span>
		<ul id="options" class="options">
      <li><label for="opA" ><input type="checkbox" name="checkbox" id="opA"  value="1"/>  A</label></li>
      <li><label for="opB" ><input type="checkbox" name="checkbox" id="opB" value="2" />  B</label></li>
      <li><label for="opC" ><input type="checkbox" name="checkbox" id="opC"  value="3"/>  C</label></li>
      <li><label for="opD"  id="op"><input type="checkbox" name="checkbox" id="opD"  value="4"/>  D</label></li>
    </ul>
	<select  id="select_id">
			<option value="111">aa</option>
			<option value="222">bb</option>
			<option value="333">cc</option>
	</select>
	<input type="button" value="test" id="test"/>
</form>
 </body>
</html>

좋은 웹페이지 즐겨찾기