use*_*567 5 javascript jquery mouseevent
假设我的鼠标从 elementA 移出并悬停在 elementB 上。
事件被解雇的顺序是什么?
mousemove, mouseleave, mouseout, mousemovex X, mouseenter, mouseover,mousemove还有更多等等...
这是我最好的猜测...
但我有点错了。这应该可以为您完成:添加您需要的事件(该示例使用 jQuery,您也可以使用纯 JavaScript 执行此操作,但我不想在这方面花费大量时间)。
好的,这是代码:
$(document).ready(function(e) {
$('.canary').on('mouseout mouseleave mouseenter mouseover', function(event){
$('#test').text($('#test').text() + ', ' + event.type) });
});
Run Code Online (Sandbox Code Playgroud)
这是你的 CSS:
.canary{
width:200px;
height:100px;
background-color:#066
}
Run Code Online (Sandbox Code Playgroud)
您的 HTML
<textarea name="test" id="test" cols="200" rows="10"></textarea>
<div class='canary'></div>
<br /><br />
<div class='canary'></div>
Run Code Online (Sandbox Code Playgroud)
这是现场演示
| 归档时间: |
|
| 查看次数: |
4024 次 |
| 最近记录: |