是否有任何 javascript 属性来检查按钮是否处于悬停状态。这是我需要的,因为当鼠标已经悬停在按钮上时,我会执行特定任务。
我可以看到事件 onMouseOver 但没有属性来检查鼠标是否悬停。
谁能帮我解决这个问题。
最佳答案
试试这个 (jQuery)。它很乱,但你明白了:
<input type="text" value="test"><input type="button" value="test">
<div id="div">-</div>
与:
$(function(){
$('*')
.data('hovering', false)
.mouseover(function(){$(this).data('hovering', true)})
.mouseout(function(){$(this).data('hovering', false)});
});
window.setInterval(function() {
$('#div').html("Textbox currently hovered: " +
$('input[type="text"]').data('hovering'));
}, 100)
关于javascript - 如何检查按钮是否悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5093645/