我想在链接上存在hover
至少1500毫秒或存在click
后显示image
。如何在显示图像时实现这个最小周期悬停条件?在链接上悬停1500毫秒后显示图片
图像应保持可见,直到链接或本身上悬停。当鼠标移出两者时,&应该消失。我怎样才能实现这个?提前致谢!
我想在链接上存在hover
至少1500毫秒或存在click
后显示image
。如何在显示图像时实现这个最小周期悬停条件?在链接上悬停1500毫秒后显示图片
图像应保持可见,直到链接或本身上悬停。当鼠标移出两者时,&应该消失。我怎样才能实现这个?提前致谢!
$('a').click(function() {
alert(1); // alert on click
})
.hover(function() { // when mouse is entering
var $this = $(this);
// set timeout, save timeout id on element to clear later
$this.data('timeout', setTimeout(function() {
$this.click(); // click after 1500ms
}, 1500));
}, function() { // when mouse is leaving
clearTimeout($(this).data('timeout')); // stop the timeout
});
某事的作用...
$("#MyLinkSelectorId").hover(function() {
//Do anything you need to do here when it is clicked/hovered
setTimeout(function() {
//Do all of the other things here
}, 1500);
});
转出与点击悬停或绑定多个事件采取两种事件类型的护理。要隐藏图像,可以使用.hide()方法在图像上使用选择器,或者如果浏览器支持,可以设置不透明度。
$("a.class").hover(function(){ //First parameter is onmouseenter, show the image
$("img").show();
}, function(){ //second is onmouseleave, set a timeout that will hide the image
setTimeout(function(){
$("img").hide();
}, 1500);
}).click(function() { //on click, hide the image right away.
$("img").hide();
});
试试这个
var hoverTimer;
$("linkSelector").hover(function() {
hoverTimer = setTimeout(function() {
$("imgSelector").show();
}, 1500);
}, function(){
clearTimeout(hoverTimer);
}).click(function(){
clearTimeout(hoverTimer);
$("imgSelector").show();
});
因为它看起来像你还没有尝试过的东西,我给你使用jQuery(请注意我的避风港最简单的方法't tted this):
$("#idOfDiv").mouseover(function() {
setTimeout("alertMsg()",1500);
});
function alertMsg()
{
alert('Ive been entered for 1500ms')
}
另外,如果你认真对待软件开发,你应该能够自己想出这个。
你尝试过什么吗? – FishBasketGordo