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("打开");
           })

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值