宝哥软件园

hover()方法在JQuery中的应用介绍简介——事件切换

编辑:宝哥软件园 来源:互联网 时间:2021-10-03

1.在JQuery中,有两种切换事件的方法,一种是hover(),另一种是toggle()。所谓切换事件是指两个以上的事件绑定到一个元素,并在元素的动作之间切换。例如,如果一个超链接标记A想在鼠标悬停时触发一个事件,在鼠标移出时触发另一个事件,可以通过切换事件轻松实现。2.示例代码:复制的代码如下:DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN ' ' http://www . w3 . org/TR/XHTML 1/DTD/XHTML L1-Transitional . DTD ' html xmlns=' http://www . w3 . org/1999/XHTML ' head meta http-equiv=' Content-Type ' Content=' text/html;Charset=utf-8'/title切换事件悬停/title script type=' text/JavaScript ' src=' http : jquery-1 . 8 . 3 . min . js '/script type=' text/JavaScript ' $(function(){ $()。clsTitle’)。hover(function(){ $(')。clsContent ')。show();},function(){ $('。clsContent ')。hide();})}))/script/head body div class=' clsstitle ' jquery简介div class=' clscontent ' jquery是美国人John Resig在2006年创建的开源项目。其主要目的是用更少的代码/div /body /html 3实现更多的功能,渲染预览:

当鼠标移动到JQuery的介绍时:

更多资讯
游戏推荐
更多+