【发布时间】:2015-03-24 21:42:25
【问题描述】:
代码示例:
<body>
<div id="something" style="width: 50vw; height: 300px;">
</div>
<div class="else">oekdoekod</div>
</body>
问题是我只需要在悬停主体时使用光标指针效果,而不是用id="something" 悬停div。
没用
:not(#something) {
cursor: pointer;
}
但是
$(document.body).on("hover", ":not(#something, #something *)",function(e){
$(this).addClass("pointer");
e.stopPropagation();
});
用css
.pointer {
cursor: pointer;
}
它有效,但仅适用于其他元素,例如.else
如何将pointer 光标应用到hover 事件上,仅在正文上而不在#something 上?
【问题讨论】:
-
在你的 CSS *:not(#something) { cursor:pointer; 之前使用 * }