這是代碼jQuery的懸停問題
//show delete link on hover
$('li.dir, li.file').live('mouseover mouseout', function(event) {
if (event.type == 'mouseover') {
$(this).find("span.delete_file").delay(800).fadeIn('fast');
}
else{
$(this).find("span.delete_file").fadeOut('fast');
}
});
HTML
<li class="dir" title="">
<span class="pin"></span>
<span class="name">test</span>
<span class="delete_file" title="/test"></span>
<ul class="sub_folder">
</ul>
</li>
CSS
ul.sub_folder{
margin-left:15px;
padding:0;
list-style:none;
}
ul.sub_folder > li{
margin:0;
line-height: 20px;
cursor:pointer;
display:block;
}
ul.sub_folder > li:hover{
background:eee;
}
ul.sub_folder > li.file {
margin-left: 5px;
}
ul.sub_folder > li.file > span.name{
background:url("/site_images/file.png") left no-repeat;
padding-left: 20px;
}
ul.sub_folder > li.dir > span.name{
margin-left:5px;
background:url("/site_images/folder.png") left no-repeat;
padding-left: 20px;
}
ul.sub_folder > li.file > span.delete_file{
background:url("/site_images/cancel.png") left no-repeat;
padding-left: 20px;
width: 16px;
height: 16px;
}
ul.sub_folder > li.dir > span.delete_file{
margin-left:5px;
background:url("/site_images/cancel.png") left no-repeat;
padding-left: 20px;
}
ul.sub_folder > li.dir > span.pin{
background:url("/site_images/folder_arrow.png") left no-repeat;
width:10px;
height: 10px;
display: inline-block;
z-index: 1;
}
我基本上想只顯示.delete_file跨度,當你在記者<li>
問題是,當我通過其他跨度(在李)時,鼠標被算作不是「在li上」,因此span.delete_fi le淡出並連續淡入,出於同樣的原因,它直接在span.delete_file上消失,所以我不能點擊它。 我知道它必須用CSS,但我想不出任何東西,我仍然過了李,爲什麼它被認爲我不是?