zoukankan      html  css  js  c++  java
  • 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("打开");
               })

  • 相关阅读:
    不舍
    java 笔记
    Javascript 行为委托
    JavaScript 函数调用的 this词法
    Javascript 闭包
    Javascript 原型链
    理解css的BFC
    多模态检索之CCA算法
    MySQL 基础概念、基础配置、密码破解
    Python的进程和线程
  • 原文地址:https://www.cnblogs.com/shuang121/p/2466434.html
Copyright © 2011-2022 走看看