我的问题是我的孩子是绝对的位置,我必须这样做。我无法将鼠标悬停在使用悬停功能的小孩身上,因为它悬停在我的选择器上。我花了几个小时解决这个问题,但失败了。悬停()jquery未能在我的情况下正常工作
我的代码如下:
$(function() {
$("#hdCallUs").hover(function() {
$('.contact_numbers').show();
}, function() {
$('.contact_numbers').hide()
});
});
ul, li {
list-style:none
}
#hdCallUs .call_txt {
cursor: pointer;
float:right;
}
#hdCallUs .contact_numbers {
display: block;
list-style: none;
position: absolute;
top: 40px;
width: 155px;
background: #fff;
right: 0;
text-align: right;
border: 1px solid #ddd;
border-top: 0;
padding: 0;
}
#hdCallUs .contact_numbers li {
padding: 8px;
float: none;
border-bottom: 1px solid #ddd;
cursor: pointer;
}
#hdCallUs .contact_numbers li:last-child {
border-bottom: 0;
}
#hdCallUs .contact_numbers li:hover {
background: #F9F9F9;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<li id="hdCallUs"> <span class="glyphicon glyphicon-earphone"></span>
<span class="call_txt">Call Now</span>
<div class="contact_numbers" style="display:none">
<ul>
<!-- added this -->
<li>999</li>
<li>888</li>
</ul>
</div>
</li>
任何解决方案?
'$( “#hdCallUs,.contact_numbers”)。悬停(函数(){''_OR_ $(“#hdCallUs,#hdCallUs *“)。hover(function()' – Tushar
@Tushar尝试过,它不起作用 –