$(document).ready(function () {
//标题鼠标经过
var word = '百度';
var site = 'HTMLPage1.htm';
$("a").mousemove(function (e) {
$(".TipDiv").remove(); //若页面上有该元素,则移除该元素...
var x = event.offsetX + 10; //获取鼠标的x轴坐标
var y = event.offsetY + 10; //获取鼠标的y轴坐标
popDiv(site, word, x, y);
})
//鼠标离开面板
$(".TipDiv").hover(function () {
alert("dfsfsd");
$(".TipDiv").fadeIn("fast");
},
function () {
$(".TipDiv").fadeOut("fast");
}
);
//标题鼠标离开链接
$("a").mouseout(function () {
//$(".TipDiv").fadeOut("1000");
$(".TipDiv").remove();
});});//随鼠标移动的信息框
function popDiv(site, word, xx, yy) {
var str = "";
str += "<div class='TipDiv'>";
str += "<a id=tip href=" + site + ">" + word + "</a>";
str += "<em>链接</em><br />";
str += "</div>";
$("body").append(str);
$(".TipDiv").css({ position: "absolute", "top": yy + "px", "left": xx + "px", "fadeIn": 1000 });
$(".TipDiv").css({ border: "solid 6px silver" });
$(".TipDiv").css({ overflow: "scroll",height:" 100px", width: "300px" });
$(".TipDiv").css("background","gray");
};
//标题鼠标经过
var word = '百度';
var site = 'HTMLPage1.htm';
$("a").mousemove(function (e) {
$(".TipDiv").remove(); //若页面上有该元素,则移除该元素...
var x = event.offsetX + 10; //获取鼠标的x轴坐标
var y = event.offsetY + 10; //获取鼠标的y轴坐标
popDiv(site, word, x, y);
})
//鼠标离开面板
$(".TipDiv").hover(function () {
alert("dfsfsd");
$(".TipDiv").fadeIn("fast");
},
function () {
$(".TipDiv").fadeOut("fast");
}
);
//标题鼠标离开链接
$("a").mouseout(function () {
//$(".TipDiv").fadeOut("1000");
$(".TipDiv").remove();
});});//随鼠标移动的信息框
function popDiv(site, word, xx, yy) {
var str = "";
str += "<div class='TipDiv'>";
str += "<a id=tip href=" + site + ">" + word + "</a>";
str += "<em>链接</em><br />";
str += "</div>";
$("body").append(str);
$(".TipDiv").css({ position: "absolute", "top": yy + "px", "left": xx + "px", "fadeIn": 1000 });
$(".TipDiv").css({ border: "solid 6px silver" });
$(".TipDiv").css({ overflow: "scroll",height:" 100px", width: "300px" });
$(".TipDiv").css("background","gray");
};
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="StyleSheet1.css" rel="stylesheet" type="text/css" /></head>
<body>
<a href="HTMLPage1.htm">HTMLPage1.htm</a>
<script src="jquery-1.4.1.js" type="text/javascript"></script>
<script src="JScript1.js" type="text/javascript"></script></body>
</html>
事件不能触发 没能执行js方法怎么能有效果呢?
function doSubmit(){
alert("执行成功!");
}
</script>
<a href="HTMLPage1.htm" onmousover="doSubmit()">HTMLPage1.htm</a>这样才能执行吧
<script>
function divDispear(){
document.getElementById("divId").style.display='none';
}<div onmouserover="divDispear()">
你试试这个方法
</div>
</script>
然后你吧div这样做<script>
function divDispear(){
document.getElementById("divId").style.display='none';
}
</script><div onmouserover="divDispear()">
</div>试试 应该可以
alert("dfsfsd");
$(".TipDiv").fadeIn("fast");
},
function () {
$(".TipDiv").fadeOut("fast");
}
);
你这样写有什么意义吗?!
现在我要实现的是,当鼠标在链接是跳出一个tooltip类似的。然后当鼠标移开链接时消失。其中tooltip内也是有东西的,当鼠标在这个tooltip内时不会消失,而移离这个区域时 再消失。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
var tid = null;
$(document).ready(function () {
//标题鼠标经过
var word = '百度';
var site = 'HTMLPage1.htm';
$("a").mousemove(function (e) {
}) $("a").mouseover(function(e) {
$(".TipDiv").remove(); //若页面上有该元素,则移除该元素...
if(tid!=null) {clearTimeout(tid);tid=null};
var x = event.offsetX + 10; //获取鼠标的x轴坐标
var y = event.offsetY + 10; //获取鼠标的y轴坐标
popDiv(site, word, x, y);
//鼠标离开面板
$(".TipDiv").hover(function(){
if(tid!=null) {clearTimeout(tid);tid=null};
$(".TipDiv").fadeIn("fast");
},
function () {
$(".TipDiv").fadeOut("fast");
}
);
}); //标题鼠标离开链接
$("a").mouseout(function () {
tid = setTimeout(outit, 1000);
});
});function outit(){
$(".TipDiv").fadeOut("fast");
}
//随鼠标移动的信息框
function popDiv(site, word, xx, yy) {
var str = "";
str += "<div class='TipDiv'>";
str += "<a id=tip href=" + site + ">" + word + "</a>";
str += "<em>链接</em><br />";
str += "</div>";
$("body").append(str);
$(".TipDiv").css({ position: "absolute", "top": yy + "px", "left": xx + "px", "fadeIn": 1000 });
$(".TipDiv").css({ border: "solid 6px silver" });
$(".TipDiv").css({ overflow: "scroll",height:" 100px", width: "300px" });
$(".TipDiv").css("background","gray");
};
</script><a href="xx">xxxxxx</a>
<div class="TipDiv" style="background:red"></div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
//标题鼠标经过
var word = '百度';
var site = 'HTMLPage1.htm';
$("a").mouseover(function (e) {
$(".TipDiv").remove(); //若页面上有该元素,则移除该元素...
var x = event.offsetX + 10; //获取鼠标的x轴坐标
var y = event.offsetY + 10; //获取鼠标的y轴坐标
popDiv(site, word, x, y);
}) //鼠标离开面板
//标题鼠标离开链接
}); //随鼠标移动的信息框
function popDiv(site, word, xx, yy) {
var str = "";
str += "<div class='TipDiv'>";
str += "<a id=tip href=" + site + ">" + word + "</a>";
str += "<em>链接</em><br />";
str += "</div>";
$("body").append(str);
$(".TipDiv").css({ position: "absolute", "top": yy + "px", "left": xx + "px", "fadeIn": 1000 });
$(".TipDiv").css({ border: "solid 6px silver" });
$(".TipDiv").css({ overflow: "scroll", height: " 100px", width: "300px" });
$(".TipDiv").css("background", "gray");
$(".TipDiv").hover(function () {
alert("dfsfsd");
$(".TipDiv").fadeIn("fast");
},
function () {
$(".TipDiv").fadeOut("fast");
}
);
};</script>
</head>
<body>
<a href="HTMLPage1.htm">HTMLPage1.htm</a></body>
</html>
//$(".TipDiv").fadeOut("1000");
$(".TipDiv").remove();
});});
它肯定是会先执行完a的事件。。
-----
你的代码 不断创建div, 最先设置的$(".TipDiv").hover对新建的div是没有用的。
不是按不按顺序的问题是要一件事情要完成才能去完成别的事情。。你好好想下把你要把鼠标移到DIV上。。是不是就出发了LEAVE a 的事件。。你可以去研究下CSDN上的代码。。移到头像图片上的这个JS