jquery——write less,do more

rite less, do more.这句话想必是很多语言都提倡的。

在此举三个jquery的应用体现

一.绑定多个事件类型

    $("div").bind("mouseover mouseout", function () {
        $(this).toggleClass("over");
    });

二.链式代码 

$("div").bind("mouseover", function(){...}).bind("mouseout",function(){...});
$("div").unbind("mouseover").unbind("mouseout");

三.事件类型中的命名空间

    $("div").bind("mouseover.plugin mouseout.plugin click", function () {
        $(this).toggleClass("over");
    });

如果要移除div的mouseover和mouseout,使用$("div").unbind(".plugin"),而div的click事件不会被移除。  

  

 

posted @ 2014-06-08 23:03  paulhe  阅读(495)  评论(0编辑  收藏  举报
friendster counter