zoukankan      html  css  js  c++  java
  • jquery常见操作总结

     

    var value= $("input:radio[name='per'][checked]").val();

    $("input[name='testradio']:eq(1)").attr("checked","checked");//
    eq(1)表示第二个
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html lang='zh-CN' xml:lang='zh-CN' xmlns='http://www.w3.org/1999/xhtml'>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
       
        <script type="text/javascript" src="http://www.oschina.net/js/2012/jquery-1.7.1.min.js"></script>
       <script>
    	$(function(){
    		$("#btnGetRadioValue").click(function(){
    			var value=$("input:radio[name='per'][checked]").val();
    			alert(value);
    		});
    		$("#btnSetRadioValue").click(function(){
    			var value=$("input:radio[name='per'][checked]").val();
    			value=value*1-1;
    			if(value==0)
    				value=1;
    			else
    				value=0;
    			$("input:radio[name='per']:eq("+value+")").attr("checked","checked");
    		});
    		$("#btnGetSelectValue").click(function(){
    			var value=$("#ddl").val();
    			alert(value);
    		});
    		
    		$("#btnSetSelectValue").click(function(){
    			var value=$("#ddl option:eq(2)").attr("selected","selected");
    		});
    	});
       </script>
      </head>
    <body>
     1<input type="radio" name="per" value="1"/>
     2<input type="radio" name="per" value="2"/>
     <input type="button" value="GetRadioValue" id="btnGetRadioValue"/>
     <input type="button" value="SetRadioValue" id="btnSetRadioValue"/><br/>
     <select id="ddl">
    	<option value="-1">--</option>
    	<option value="1">1</option>
    	<option value="2">2</option>
     </select>
     <input type="button" value="GetSelectValue" id="btnGetSelectValue"/>
      <input type="button" value="SetSelectValue" id="btnSetSelectValue"/>
    </body>
    </html>
     
    
  • 相关阅读:
    4QC(四象限变流器)
    SR锁存器
    JVM 专题二:虚拟机(二)Java虚拟机
    JVM 专题一:虚拟机(一)
    Scala 基础(一):各平台安装
    shell专题(十一):企业真实面试题(重点)
    shell专题(十):Shell工具(重点)
    shell专题(九):函数
    shell专题(八):read读取控制台输入
    shell专题(七):流程控制(重点)
  • 原文地址:https://www.cnblogs.com/humble/p/3039851.html
Copyright © 2011-2022 走看看