JQuery版本更替函数变化以及toggle被删除后的替代方法

  1. live() 1.9以上被淘汰。 替代函数:.on()。
  2. die() 1.9以上被淘汰。 替代函数:.off()。
  3. .size() 1.8以上被淘汰。替代函数:.length。
  4. .toggle() 1.8以上被淘汰。

  • 方法1:
$(".one .top").click(function() {
            if($(".content").css("display")=="none"){
                 $(".content").show(1500);
                 $(".iocn").addClass("jian");
            }else {

                 $(".content").hide("slow");
                 $(".iocn").addClass("jia");
            }

        });

  • 方法2:
var i=0;
        $(".one .top").click(function() {
            if(i==0){
                 $(".content").hide("slow");
                 $(".iocn").addClass("jia");
                 i=1;
            }else  {
                 $(".content").show(1500);
                 $(".iocn").addClass("jian");
                 i=0;
            }

        });

猜你喜欢

转载自blog.csdn.net/qq_42207957/article/details/80497409