通过 jQuery 设置时光标不会改变

发布于 2024-12-24 17:23:17 字数 503 浏览 2 评论 0原文

您好,我编写了一个小脚本,其中每次触发状态 1 时,光标都会更改为指针,而当触发状态 2 时,它会更改为十字准线。 两种状态都被正确触发,一切都运行良好,除了每次我处于状态 1 时,只有我希望光标更改的 div 之一显示正确的光标。 在状态 2 中,一切都按其应有的方式进行。

HTML

<div id='first'></div>
<div id='second'></div>

JS

function state1 (){
$('#first').css({'cursor':'pointer'});
$('#second').css({'cursor':'pointer'});
};

function state2 (){
$('#first').css({'cursor':'crosshair'});
$('#second').css({'cursor':'crosshair'});
};

Hi I wrote a little script where every time state 1 is triggered the cursor changes to a pointer, and when state 2 is triggered it changes to a crosshair.
Both states get triggered correctly and everything runs fine, except every time I am in state 1 only one of the divs which I want the cursor to change for show the right cursor.
In state 2 everthing works like it should.

HTML

<div id='first'></div>
<div id='second'></div>

JS

function state1 (){
$('#first').css({'cursor':'pointer'});
$('#second').css({'cursor':'pointer'});
};

function state2 (){
$('#first').css({'cursor':'crosshair'});
$('#second').css({'cursor':'crosshair'});
};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白日梦 2024-12-31 17:23:17

您没有在代码中正确执行函数 state1

You don't execute function state1 properly in the code

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文