jquery怎么修改hover事件

584 ℃

jquery怎么修改hover事件,下面web建站小编给大家详细介绍一下!

代码如下:

$(document).ready(function() {
  $("p").hover(function() {
    $("p").css("background-color", "red");
  }, function() {
    $("p").css("background-color", "blue");
  });
  
  $("button").click(function() {
    $("p").unbind("mouseenter").unbind("mouseleave");
  });
});

拓展介绍

/* 这种方法是错误的 */
$("id").unbind("hover");

/* 这种方法也是错误的 */
$("id").unbind("mouseover").unbind("mouseout");

/* 这种方法是新增的,在老的版本里是无法使用的 */
$("id").unbind("mouseenter mouseleave");

/* 这种方法正确的,新老版本皆可用 */
$("id").unbind("mouseenter").unbind("mouseleave");

jQuery检测指定链接(URL)是否有效(包含跨域)

jQuery语法判断元素是否有子元素的代码?

jQuery语法判断元素是否具有某个特定属性的方法?

jQuery语法如何实现table隔行交替背景色(具体代码介绍)

jQuery语法如何实现表格隔行变色效果

标签: hover事件, jquery语法, unbind

上面是“jquery怎么修改hover事件”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_2932.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

dedecms如何在文章页面获取当前url链接
帝国cms教程之网站管理系统TAGS管理
Lunar组件如何利用I18n实现多语言功能
详解dedecms使用整合阿里大鱼短信接口进行短信发
uniapp如何安装stomp并运用