zoukankan      html  css  js  c++  java
  • js toggle事件

    参数:
    even (Function): 第奇数次点击时要执行的函数。 
    odd (Function): 第偶数次点击时要执行的函数。 
    示例:
    $("p").toggle(function(){
              $(this).addClass("selected");   
            },function(){
             $(this).removeClass("selected"); 
    }); 

    toggle(even,odd) 
    Toggle between two function calls every other click. Whenever a matched element is clicked, the first specified function is fired, when clicked again, the second is fired. All subsequent clicks continue to rotate through the two functions. 

    Jquery1.9.1中 toggle(fn1,fn2...)方法 可实现点击一个元素来执行指定函数。此方法被删除以减少混乱和提高潜在的模块化程度。只保留了显示和隐藏的功能!

    Jquery1.9版本后删除 奇数/偶数次点击继续函数。

    今天用到记录一下,用下面方法代替。

    var isHidden = $("#id").is(":hidden");
    if(isHidden){
    $("#id  a").css("background-position","-23px -3px");
    }else{
    $("#id a").css("background-position","-3px -3px");
    }

  • 相关阅读:
    寒假学习进度七
    寒假学习进度六
    寒假学习进度五
    mysql 数据库第一天
    HTML 标签&总结
    事件对象
    js的事件流的概念
    jquery 的位置信息
    小米导航 案例
    jquery 的文档操作
  • 原文地址:https://www.cnblogs.com/chenweichu/p/5481346.html
Copyright © 2011-2022 走看看