可以说我有
<style>
#container:hover{background:red}
</style>
<div id="container"><input type="submit"></div>
Run Code Online (Sandbox Code Playgroud)
当我在提交时悬停,#container仍然是红色的.我可以删除它:使用jquery悬停在输入鼠标悬停上吗?我不想改变bg $('#container').css('backgroundColor','color'),我需要类似的东西 $('#container').removeAttr('hover').
Vis*_*ioN 22
不幸的是,使用jQuery管理CSS伪类是不可能的.
我建议你操作类,如下所示:
<style>
.red:hover{background:red}
</style>
<div id="container" class="red"><input type="submit"></div>
<script>
$("#container").removeClass("red");
</script>
Run Code Online (Sandbox Code Playgroud)
您无法删除伪类规则,但可以使用事件绑定覆盖它们:
$("#container").on('mouseover', function () {
$(this).css('background', 'blue');
}).on('mouseout', function () {
$(this).css('background', whateverItIsNormally);
});
Run Code Online (Sandbox Code Playgroud)