Sea*_*son 6 html javascript css css3
我有一个动态创建的HTML元素.它有一些CSS和HTML:
<div id="element"></div>
#element{
height: 200px;
width: 200px;
background-color: blue;
}
#element:hover{
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
然后,当鼠标仍然在元素上时,它将以编程方式从页面中删除.
$('#element').hover(function(){
setTimeout(function(){
$(this).remove();
}.bind(this), 1000);
});
Run Code Online (Sandbox Code Playgroud)
这使光标看起来像一个指针,直到鼠标移动.有什么办法可以解决这个问题,同时仍然使用CSS悬停?
这是一个小提琴:http://jsfiddle.net/mHdtU/
编辑:这是最新的谷歌浏览器.此外,显然HIDING元素会导致光标更新.光标未更新的事实是否删除了谷歌浏览器中的错误?
$('#element').hover(function(){
setTimeout(function(){
$(this).hide();
setTimeout($(this).remove.bind(this));
}.bind(this), 1000);
});
Run Code Online (Sandbox Code Playgroud)
不确定它是否适合您,但您可以使用
$(this).hide();
Run Code Online (Sandbox Code Playgroud)
插入.remove()以使指针返回到箭头。
根据您的回答编辑:
$('#element').hover(function(){
setTimeout(function(){
$(this).hide(0,function(){$(this).remove.bind(this)});
}.bind(this), 1000);
});
Run Code Online (Sandbox Code Playgroud)
这样,您就可以等到隐藏动画完成。