我有关于鼠标悬停的图像列表上的那些必须显示一些信息。问题是不能为info div触发鼠标事件。
#team_div{
display:block;
position:relative;
}
#pop_div{
width:300px;
padding:5px;
height:200px;
overflow:hidden;
border:2px solid #ccc;
background:#fefefe;
position:absolute;
display:none;
}
#pop_div img{
margin:10px;
display:block;
float:left;
}。
<div id="team_div" class="team_div_loading">
<div id="pop_div"></div>
<table>
list of images
</table>
</div>。
$('#team_div > table img').hover(function() {
var top = this.parentNode.offsetTop;
var left = this.parentNode.offsetLeft;
var img =$(this).attr('src');
var id =$(this).attr('id');
var content = $("#" + id + "p").html();
$("#pop_div").show();
$("#pop_div").css('top', top-11 +'px');
$("#pop_div").css('left', left-12 +'px');
$("#pop_div").html('<img src="' + img + '"/>' + content );
$("#pop_div").fadeIn(700);
});
$("#pop_div").mouseout(function(){
$("this").hide();
});在此情况下,如果为悬停图像调用函数,则不会为pop_div触发任何鼠标事件。
我很感谢你的建议。
发布于 2013-02-11 18:08:16
首先,您不能使用in元素,而是使用div或ul li结构,我是通过在
<div class="imageDiv"></div>并使用编辑jquery函数
$('#team_div>.imageDiv img').hover(function () {
var top = this.parentNode.offsetTop;
var left = this.parentNode.offsetLeft;
var img = $(this).attr('src');
var id = $(this).attr('id');
var content = $("#" + id + "p").html();
$("#pop_div").show();
$("#pop_div").css('top', top - 11 + 'px');
$("#pop_div").css('left', left - 12 + 'px');
$("#pop_div").html('<img src="' + img + '"/>' + content);
$("#pop_div").fadeIn(700);
});您只是使用了错误的jquery选择器。我不知道你试图用图像悬停功能做什么,但它正在处理上面的更改。
https://stackoverflow.com/questions/1171274
复制相似问题