我有这样的HTML,其中内部是子div,外部是父div。
我要实现的是:激活具有鼠标悬停在其上的div。
我已经调用了jQuery的悬停功能,它正在帮助我添加和删除活动类。
问题:当我将光标移到innerchild div上时,它被激活,但是当我将光标从内部div移到外部父div时,它却缓慢地被激活了。
我也跟踪了鼠标的移动。 https://jsfiddle.net/Simplybj/zaz1qh8e/2/。
结果:当内部div悬停时,不会触发外部div的mouseout
$('div').hover(
function() {
$('div').removeClass('activeHover');
$(this).addClass('activeHover');
},
function() {
$(this).removeClass('activeHover');
}
);Run Code Online (Sandbox Code Playgroud)
.outer {
background-color: #aeaeae;
height: 200px;
width: 200px;
float: left;
}
.inner {
margin: 50px;
background-color: #ccc;
height: 100px;
width: 100px;
float: left;
}
.activeHover {
background-color: green;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<div class="outer">
<div class="inner">
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我有一个可以有 n 个嵌套 div 标签的环境。我必须仅在子 div 中跟踪鼠标的鼠标移动时刻。
我有以下代码。结果显示在列表中。
问题:如果我附加更多子“div”,鼠标移动也会跟踪所有父级 div。
我想要的是:仅获取鼠标悬停区域的鼠标轨迹。
我还尝试使用 is:hover 进行过滤,但所有元素都悬停。 JSF闲置
var count = 0;
$('div').on({
mousemove: function(event) {
$('.mousemovement').append('<li>MouseMove' + $(this).attr('class') + '</li>');
if (count > 10) {
$('.mousemovement').html('');
count = 0;
}
count++;
}
});Run Code Online (Sandbox Code Playgroud)
.outer {
background-color: #aeaeae;
height: 200px;
width: 200px;
float: left;
}
.inner {
margin: 5px 0px;
background-color: #ccc;
height: 100px;
width: 100px;
float: left;
}
.inner2 {
margin: 5px 0px;
background-color: green;
height: 60px;
width: 60px;
float: …Run Code Online (Sandbox Code Playgroud)我想绘制不同的点,并在jQuery中的图表中显示数据.如果可以使用jQuery绘制斜率线,那么绘制图表会更容易.有没有办法在jQuery中绘制斜率?