我需要使通知列表出現在點擊工作正常。但是onblur()根本不工作。 這裏是小提琴:http://jsfiddle.net/eX2zQ/onblur()不工作,而onclick()工作正常
代碼:
HTML: -
<div class="one" onclick="hidetwo();" onblur="remove_the_notification();">
<div>
<ul class="dropdown" id="notification" >
<li><a href="#">kjhlkjhkjhklhjklj</a></li>
<li><a href="#">kjhlkjhkjhklhjklj</a></li>
<li><a href="#">kjhlkjhkjhklhjklj</a></li>
<li><a href="#">See_All</a></li>
</ul>
</div>
</div>
CSS: -
.one{
overflow: visible;
width: 21px;
height: 21px;
background-color:black;
}
JS: -
var show=0;
function hidetwo(){
if (show==0){
document.getElementById('notification').style.display="block";
show=1;
}
else if (show==1){
document.getElementById('notification').style.display="none";
show=0;
}
}
function remove_the_notification(){
alert('hide one');
if (show==0){
document.getElementById('notification').style.display="block";
show=1;
}
else if (show==1){
document.getElementById('notification').style.display="none";
show=0;
}
}
實測值[講講](http://help.dottoro.com/ljewsllu.php)'onmouseleave'。 「onmouseleave事件只有Internet Explorer支持,對於跨瀏覽器解決方案,使用onmouseout事件。onmouseleave和onmouseout事件之間的唯一區別是onmouseout事件向上傳播文檔層次結構,而onmouseleave事件不傳播。 – KoalaBear
非常感謝。 onmouseleave正在完美工作。我以前不知道這一點。 –