gpt4 book ai didi

javascript - 浏览器之间的鼠标事件光标差异

转载 作者:搜寻专家 更新时间:2023-11-01 04:35:33 24 4
gpt4 key购买 nike

我使用鼠标悬停来获取光标类型,当由于某种原因鼠标悬停时,我在 Chrome 和 Firefox 中得到不同的结果,Chrome 中的光标样式是“自动”,而在 Firefox 中是“文本”。我需要知道光标在两个浏览器中什么时候是默认的,什么时候是自动的(因为它应该在文本输入上)或文本。 .

我在这里写了一个简单的代码来重现这个问题,在 Chrome 和 Firefox 上尝试一下,看看有什么不同(如果你想玩代码,这里是 jsfiddle)。

提前致谢:)

window.onmouseover=function(event) {
var currentCursor = $(event.target).css('cursor');
console.log(currentCursor);
$('#pointer').html(currentCursor);
};
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<input type="text" width="100">
<p>Move the mouse in and out the input field</p>
<p id='pointer'></p>

最佳答案

Chrome 和 Firefox 可能使用不同的输入控件默认表。

如果您想确保可以设置自己的样式表并强制光标成为文本输入的“文本”。

window.onmouseover=function(event) {
var currentCursor = $(event.target).css('cursor');
console.log(currentCursor);
$('#pointer').html(currentCursor);
};
input[type="text"] {
cursor:text
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<input type="text" width="100">
<p>Move the mouse in and out the input field</p>
<p id='pointer'></p>

关于javascript - 浏览器之间的鼠标事件光标差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39048851/

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