zoukankan      html  css  js  c++  java
  • jQuery监听事件经典例子



    关键字:jQuery监听事件经典例子 


    js代码: 
    ============================================================ 

    $(function(){ 
       $("#s1 option:first,#s2 option:first").attr("selected",true); 
      
       $("#s1").dblclick(function(){ 
         var alloptions = $("#s1 option"); 
         var so = $("#s1 option:selected"); 

         so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
        
         $("#s2").append(so); 
       }); 
      
       $("#s2").dblclick(function(){ 
         var alloptions = $("#s2 option"); 
         var so = $("#s2 option:selected"); 
        
         so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
        
         $("#s1").append(so); 
       }); 
      
       $("#add").click(function(){ 
         var alloptions = $("#s1 option"); 
         var so = $("#s1 option:selected"); 

         so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
        
         $("#s2").append(so); 
       }); 
      
       $("#remove").click(function(){ 
         var alloptions = $("#s2 option"); 
         var so = $("#s2 option:selected"); 
        
         so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
        
         $("#s1").append(so); 
       }); 
      
       $("#addall").click(function(){ 
         $("#s2").append($("#s1 option").attr("selected",true)); 
       }); 
      
       $("#removeall").click(function(){ 
         $("#s1").append($("#s2 option").attr("selected",true)); 
       }); 
      
       $("#s1up").click(function(){ 
         var so = $("#s1 option:selected"); 
         if(so.get(0).index!=0){ 
           so.each(function(){ 
               $(this).prev().before($(this)); 
           }); 
         } 
       }); 
      
       $("#s1down").click(function(){ 
         var alloptions = $("#s1 option"); 
         var so = $("#s1 option:selected"); 
        
         if(so.get(so.length-1).index!=alloptions.length-1){ 
           for(i=so.length-1;i>=0;i--) 
           { 
             var item = $(so.get(i)); 
             item.insertAfter(item.next()); 
           } 
         } 
       }); 
      
       $("#s2up").click(function(){ 
         var so = $("#s2 option:selected"); 
         if(so.get(0).index!=0){ 
           so.each(function(){ 
               $(this).prev().before($(this)); 
           }); 
         } 
       }); 
      
       $("#s2down").click(function(){ 
         var alloptions = $("#s2 option"); 
         var so = $("#s2 option:selected"); 
        
         if(so.get(so.length-1).index!=alloptions.length-1){ 
           for(i=so.length-1;i>=0;i--) 
           { 
             var item = $(so.get(i)); 
             item.insertAfter(item.next()); 
           } 
         } 
       }); 
    }); 
  • 相关阅读:
    性能篇系列—stream详解
    Java正则表达式详细解析
    干货系列性能篇之——序列化
    面试官之问:知道你的接口“QPS”是多少吗?
    Java性能之优化RPC网络通信
    Spring之 JDBC 异常
    Java性能之synchronized锁的优化
    浅谈Java中switch分支语句
    Spring Boot 之异步执行方法
    Java性能 -- Lock优化
  • 原文地址:https://www.cnblogs.com/baiduligang/p/4247128.html
Copyright © 2011-2022 走看看