我在页面的div区域应用了mouseenter事件时遇到了一些麻烦。我正在尝试在鼠标输入时更改此div的背景颜色,但都被忽略了。
我有一个简单的HTML代码:
<div id="services" class="services">
<div id="services-top">
<h2>Services</h2>
</div>
<div id="services-content">
<div id="services-content-left">
<img id="services-content-right-img" class="img-circle" src="http://i.imgur.com/vN5m4vK.jpg" alt="empty">
<h3>STUFF</h3>
</div>
</div>
</div>
和JS一起发生的事件:
$(document).ready(function() {
$("services-content-left").mouseenter(function() {
console.log("enter");
$(this).css("background-color", "yellow");
});
});
正如我之前所说,当我进入该div区域时,背景保持不变,没有任何更改。这里是一个例子。
你不知道如何解决吗?
你只是错过了
$(document).ready(function() {
$("#services-content-left").mouseenter(function() {
console.log("enter");
$(this).css("background-color", "yellow");
});
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句