用jQuery删除css:hover属性 [英] remove css :hover attribute with jquery

查看:916
本文介绍了用jQuery删除css:hover属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我说我有

<style>
    #container:hover{background:red}
</style>
<div id="container"><input type="submit"></div>

当我将鼠标悬停在提交时,#container仍然是红色.我可以使用jquery在输入mouseover上删除:hover吗?我不想更改bg $('#container').css('backgroundColor','color'),我需要类似$('#container').removeAttr('hover')的东西.

When I hover on submit, #container is still red. Can I remove that :hover on input mouseover with jquery? I do not want to change bg $('#container').css('backgroundColor','color'), I need something like $('#container').removeAttr('hover').

推荐答案

不幸的是,无法使用jQuery管理CSS伪类.

Unfortunately it is impossible to manage CSS pseudo-classes with jQuery.

我建议您如下操作类:

<style>
    .red:hover{background:red}
</style>

<div id="container" class="red"><input type="submit"></div>

<script>
    $("#container").removeClass("red");
</script>

这篇关于用jQuery删除css:hover属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆