jQuery案例_@注册时选择阅读条款_@左右移动

注册时选择阅读条款

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  2. <html>  
  3.   <head>  
  4.     <title>demo2.html</title>  
  5.       
  6.     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  
  7.     <meta http-equiv="description" content="this is my page">  
  8.     <meta http-equiv="content-type" content="text/html; charset=UTF-8">  
  9.       
  10.     <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->  
  11.   
  12. <script type="text/javascript" src="../js/jquery-1.9.1.js"></script>  
  13.   
  14. <script type="text/javascript">  
  15.     $(document).ready(function(){  
  16.         var $submitBtn=$("#submitBtn");//获取按钮对象  
  17.         //为按钮注册点击事件  
  18.         $submitBtn.click(function(){  
  19.             //alert("我被点击了!");  
  20.         });  
  21.           
  22.         //第二种  绑定事件 第一个参数是绑定事件的类型,第二个参数是触发的函数  
  23.         $(submitBtn).bind("click",function(){  
  24.             var $check=$("#agree");//获取checkbook的元素对象  
  25.             //把jQuery转换成Dom对象  
  26.             /*var checkDom=$check[0];  
  27.             if(checkDom.checked){  
  28.                 alert("同意注册!");  
  29.             }else{  
  30.                 alert("请选择同意条款!");  
  31.             }*/  
  32.               
  33.             if($check.is(":checked")){  
  34.                 alert("同意注册!");   
  35.             }else{  
  36.                 alert("请选择同意条款!");  
  37.             }  
  38.         });  
  39.     });  
  40.       
  41.           
  42.       
  43.   
  44. </script>  
  45.   
  46.   </head>  
  47.     
  48.   <body>  
  49.     注册条款:<input type="checkbox" id="agree"/>我已仔细阅读并接受csdn注册条款。  
  50.     <input type="submit" value="注册" id="submitBtn"/>  
  51.   </body>  
  52. </html> 

左右移动  ------------------------------------------------------------

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  
  2. <html>  
  3.   <head>  
  4.     <title>demo03.html</title>  
  5.       
  6.     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">  
  7.     <meta http-equiv="description" content="this is my page">  
  8.     <meta http-equiv="content-type" content="text/html; charset=UTF-8">  
  9.       
  10.     <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->  
  11. <script type="text/javascript" src="../js/jquery-1.9.1.js"></script>  
  12. <script type="text/javascript">  
  13.       
  14.       
  15.      $(document).ready(function(){  
  16.             var $romve=$("#romve");  
  17.             var $romves=$("#romves");  
  18.               
  19.             $romve.click(function(){  
  20.                 var $opts=$("#ropt>option:selected");  
  21.                 $opts.appendTo("#lopt");  
  22.               
  23.             });  
  24.               
  25.             $romves.bind("click",function(){  
  26.                 var $opts=$("#ropt>option");  
  27.                 alert($opts.length);  
  28.                 $opts.appendTo("#lopt");  
  29.             });  
  30.               
  31.             //双击  
  32.             $("#ropt").bind("dblclick",function(){  
  33.                 var $pots=$("#ropt>option:checked");  
  34.                 $pots.appendTo("#lopt");  
  35.             });  
  36.            
  37.          });  
  38.        
  39.      $(document).ready(function(){  
  40.             var $lromve=$("#lromve");  
  41.             var $lromves=$("#lromves");  
  42.             //注册click事件  
  43.             $lromve.click(function(){  
  44.                 var $opts=$("#lopt>option:selected");  
  45.                 $opts.appendTo("#ropt");  
  46.               
  47.             });  
  48.             //绑定事件  
  49.              $lromves.bind("click",function(){  
  50.                 var $opts=$("#lopt>option");//获取所有的option  
  51.                   
  52.                 //alert($opts.length);  
  53.                 $opts.appendTo("#ropt");  
  54.                 //$("#ropt").append($opts);  
  55.              });  
  56.               
  57.             //双击  
  58.             $("#lopt").bind("dblclick",function(){  
  59.                 var $opts=$("#lopt>option:checked");//获取所有的option  
  60.                 $opts.appendTo("#ropt");  
  61.             });  
  62.               
  63.         });  
  64.   
  65. </script>  
  66.   </head>  
  67.     
  68.   <body>  
  69.          
  70.        <h1 align="center">左右漂移</h1>  
  71.          
  72.        <div style="position: absolute; left: 450px; top: 120px">  
  73.           <div style="float:left; width: 200px; height: 300px; background-color:lightsteelblue; text-align: center;"><br><br>  
  74.                         
  75.                       <select id="lopt" multiple="multiple" size="9" style="width: 80px;">  
  76.                                           <option>aa</option>  
  77.                                           <option>bb</option>  
  78.                                           <option>cc</option>  
  79.                                           <option>dd</option>  
  80.                                           <option>ee</option>  
  81.                                           <option>ff</option>  
  82.                                           <option>gg</option>  
  83.                                           <option>hh</option>  
  84.                                           <option>pp</option>                
  85.                       </select>  
  86.                        <br/><br/>  
  87.                       <input type="button" id="lromve" value="选中的右移" style="width: 80px;"/><br/><br/>  
  88.                       <input type="button" id="lromves" value="全部右移" style="width: 80px;"/>  
  89.             
  90.           </div>  
  91.           <div style ="width: 200px; height: 300px; background-color: #bbffaa; text-align: center;"><br><br>  
  92.              
  93.                       <select id="ropt" multiple="multiple" size="9" style="width: 80px;">  
  94.                                           <option>选项1</option>  
  95.                                           <option>选项2</option>  
  96.                                           <option>选项3</option>  
  97.                                           <option>选项4</option>  
  98.                                           <option>选项5</option>  
  99.                                           <option>选项6</option>  
  100.                                           <option>选项7</option>  
  101.                                           <option>选项8</option>  
  102.                                           <option>选项9</option>           
  103.                       </select>  
  104.                         
  105.                        <br/><br/>  
  106.                       <input type="button" id="romve" value="选中的左移" style="width: 80px;"/><br/><br/>  
  107.                       <input type="button" id="romves" value="全部左移" style="width: 80px;"/>  
  108.             
  109.           </div>  
  110.        </div>  
  111.   </body>  
  112. </html>  

 

posted @ 2013-04-11 08:07  chrp99  阅读(218)  评论(0编辑  收藏  举报