JQuery - :visible 不起作用

发布于 2024-12-23 17:11:38 字数 373 浏览 3 评论 0原文

我有一个带有 id 的 div,其首选项存储在 .css 文件中。 div 隐藏在开头 (display:none),当用户在表单中输入内容时,我用 $(elem).hide().fadeIn();< 显示 div /code> 一切正常。

我只是想检查一下,如果使用 ESC 键,div 是否可见。我用 if($(elem).is(':visible')$('#suchergebnis').css('display') == 'block' 尝试过code>.

我回显了显示属性,即使 div 可见,它也始终显示“无”。

这是怎么回事?我该如何解决它?

I have a div with an id, whose preferences are stored in a .css file. The div is hidden in the beginning (display:none) and when the user types something into a form I show the div with $(elem).hide().fadeIn(); and everything works okay.

I just want to check, in case the ESC key is used, whether the div is visible or not. I tried it with if($(elem).is(':visible') and $('#suchergebnis').css('display') == 'block'.

I echoed the display property and it always shows 'none' even when the div is visible.

How can this be and how can I solve it?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文