您好我有下面的代碼彈出的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" dir="ltr">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js" type="text/javascript"></script>
<style type="text/css">
.card {
border:1px solid transparent;
cursor:pointer;
float:left;
height:136px;
margin:10px;
padding:3px;
width:136px;
}
.ui-corner-all {
-moz-border-radius:4px 4px 4px 4px !important;
}
</style>
</head>
<body>
<!-- <div id="popupContact" style="position:absolute;left:100px;top:100px;width:100px;height:50px;background-color:orange;border:1px solid red ;">
</div> -->
<div class="card ui-corner-all" id="card-208">
<div class="card-name"> Rahul1's Gib 1 </div>
</div>
</body>
</html>
<script type='text/javascript'>
$(document).ready(function(){
var popup_pos=$('#card-208').offset();
var timer;
$("#card-208").mouseenter(function() {
if($("#divtoshow").length==0){
$("#card-208").append('<div id="divtoshow" style="display:block;background-color:green; border:1px solid black;width:200px;height:100px;position:absolute;">'+
'dsfdssd <a href="#">rahul</a>'+
'</div>')
}
$("#divtoshow").css('position',"absolute");
$("#divtoshow").css('top',popup_pos.top-120);
$("#divtoshow").css('left',popup_pos.left-120);
//~ $("#divtoshow").show();
});
$("#divtoshow").live('mouseleave', function() {
$(this).remove();
});
});
</script>
問題:爲什麼在鼠標離開的divtoshow不是隱藏它隱藏當我再次將鼠標放置到它。
問候
拉胡爾
我已經更新了http://www.jsfiddle.net/YjC6y/23/ – XMen 2010-10-19 07:03:19
爲什麼div div不會隱藏,而mouseleave – XMen 2010-10-19 07:03:53
它隱藏時,我再次採取mouseover它, – XMen 2010-10-19 07:04:17