jquery.honver(),toggle()

    类似js的onmouseover和onmouserout的功能,在jquery中可以使用honver实现,对比代码如下

    onmouseover和onmouserout:

              $(".msgtable tr").mouseover(function () {
                            $(this).addClass("tr_hover_col");
                        }).mouseout(function () {
                           $(this).removeClass("tr_hover_col"); 
                      })
           

hover:

               $(this).removeClass("tr_hover_col"); 
            //            })
            $(".msgtable tr").hover(function () {
                $(this).addClass("tr_hover_col");
            }, function () {
                $(this).removeClass("tr_hover_col"); 
            });

hover就是实现移动移除的两个函数的切换,同样类似于toggle函数,toggle主要是触发点击事件的时候,两个函数来回切换的效果,在软件框架中,点击展开隐藏左边的菜单的时候经常会用到

举个例子,现在有一个按钮,初始化的时候是按钮的值是打开,然后点击的时候,就让它的值在打开和关闭之间切换就行了

<input id="Button1" type="button" value="打开" />

 $("#Button1").toggle(function(){          
              $(this).val("关闭");
           },function(){     
            $(this).val("打开");
           })

原文地址:https://www.cnblogs.com/shuang121/p/2466434.html