我有一段里面有粗体字
<p style="class1"><b>Some text</b> some other text</p>
mouseenter
和元素mouseout
事件的jQuery 监听器class1
$('class1').mouseenter(function(){
$(this).addClass("highlight");
});
$('class1').mouseout(function(){
$(this).removeClass("highlight");
});
其中highlight
类是模拟经典 HTML 选择的样式。
.highlight{
background-color: blue;
color: white !important
}
(我没有使用 style1:hover 因为我想以编程方式模拟也用箭头选择,但这现在并不重要)
所以,我有一些这样的段落:
一些文字一些其他文字
一些文字一些其他文字
一些文字一些其他文字
现在,我的问题是,当鼠标光标从粗体文本传递到普通文本(或反之亦然)时,mouseout
事件触发,失去我的假选择,但停留在同一段落中。我怎样才能避免这种行为?