gpt4 book ai didi

javascript - 选择列表在 jQuery 中的 Option 悬停时关闭 在悬停时显示/隐藏 Div

转载 作者:行者123 更新时间:2023-11-28 18:30:40 24 4
gpt4 key购买 nike

我已经通过 jQuery 设置了一个 div 以在悬停某个元素时显示和隐藏。在 div 中,我有下拉菜单,但是当我单击“选择列表”并将鼠标悬停在“选项列表”上时,“选择菜单”会立即关闭。

jQuery:

        <script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){

$(".tiptext").mouseover(function() {
$(this).children(".description").show();
}).mouseout(function() {
$(this).children(".description").hide();
});


});//]]>
</script>

HTML:

    <div class="description" style="display: none;">

<div id="tab1">
<h2>Calendar Use</h2>
<p>Available dates are marked in white, those unavailable are black. The holiday villa is available from 4:00pm on the day of arrival and needs to be vacated by 10:00am on the day of departure. If you have earlier flight arrival times kindly contact us directly.</p>
</div>

<div id="tab2">
<h2>Check Availability</h2>
<br><p>Arrival Date</p>
<div id="calendar-titles"><span class="day-t">day</span><span class="month-t">month</span><span class="year-t">year</span></div>

<form method="post" action="">

<div id="calendar-container"><select id="year2Sel" name="year2Sel" onchange="showRSS(document.getElementById('field2').value"></select><select id="monthSel" name="monthSel" onclick="showRSS(document.getElementById('field2').value, document.getElementById('yearSel').value, this.value, document.getElementById('daySel').value )"><option value="0">January</option><option value="1">February</option><option value="2">March</option><option value="3">April</option><option value="4">May</option><option value="5">June</option><option value="6">July</option><option value="7">August</option><option value="8">September</option><option value="9">October</option><option value="10">November</option><option value="11">December</option></select><select id="daySel" name="daySel" onchange="showRSS(document.getElementById('field2').value, document.getElementById('yearSel').value, document.getElementById('monthSel').value, this.value )"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select></div>
<select id="yearSel" name="yearSel" onchange="showRSS(document.getElementById('field2').value, document.getElementById('yearSel').value, document.getElementById('monthSel').value, document.getElementById('daySel').value)">
<option value="2013">2013</option>
<option value="2014">2014</option>
</select>

<div id="avail-left">
<p>No of Nights</p>
<span>min stay: 7 nights</span>

<input type="text" id="field2" name="nights" onkeyup="showRSS(this.value, document.getElementById('yearSel').value, document.getElementById('monthSel').value, document.getElementById('daySel').value)" value="" alt="Test" onkeypress="return isNumberKey(event)" onchange="isValid();">

</div>
<div id="avail-right">
<p>Est. Rate</p>
<div id="rssOutput"></div></div>

<input type="submit" value="Enquire" name="submit" class="enquirebtn">
</form>

<br>



</div>

<div id="tab3">
<iframe width="243px" height="221px" src="/calendar/index.php" frameborder="0" border="0" style="border:0px;"></iframe>
</div>

</div>

有人对如何解决这个问题有建议吗?

最佳答案

使用 mouseentermouseleave 代替 mouseovermouseout

the mouseover and mouseout events fire for a given element if the user mouses over or out of an element nested within the given element.

    $(".tiptext").mouseenter(function() {
$(this).children(".description").show();
}).mouseleave(function() {
$(this).children(".description").hide();
});

通过这个 link如果您想知道它们之间的区别,将会有所帮助

关于javascript - 选择列表在 jQuery 中的 Option 悬停时关闭 在悬停时显示/隐藏 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14456688/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com