gpt4 book ai didi

javascript - 为什么 onmouseout 在选择标签内调用每个选项更改

转载 作者:行者123 更新时间:2023-11-30 09:29:01 25 4
gpt4 key购买 nike

多选选项调用onmouseout函数,每一个选项变化都没有从选择框出来,请问这个事件问题的原因是什么?

修复了从 select 标签中删除 multiple 属性时的错误。

function mout(e){
console.log("mouse is out");
}
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<select id="x" multiple onmouseout="mout(this)">
<option value="1">11:00 10-10-2017</option>
<option value="2">11:00 10-10-2017</option>
<option value="3">13:00 10-10-2017</option>
</select>

最佳答案

使用 mouseleave

The mouseout event triggers when the mouse pointer leaves any child elements as well the selected element.

The mouseleave event is only triggered when the mouse pointer leaves the selected element.

function mout(e){
console.log("mouse is out");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<select id="x" multiple onmouseleave="mout(this)">
<option value="1">11:00 10-10-2017</option>
<option value="2">11:00 10-10-2017</option>
<option value="3">13:00 10-10-2017</option>
</select>

关于javascript - 为什么 onmouseout 在选择标签内调用每个选项更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47547095/

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