show() 之后的 jQuery 假定 display:inline 是 :hidden。为什么?

发布于 2024-09-05 05:22:53 字数 744 浏览 0 评论 0原文

在 jQuery 1.4.2 中,:hidden 过滤器不会过滤掉隐藏的元素,但我通过调用 show() 使其可见。过滤器假设它仍然是隐藏的。

这是错误还是我错过了什么?考虑以下代码:

$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").css("display")
"none"
$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").show()
Object
$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").css("display")
"inline" // ?? Let me scratch my head...
$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").is(":hidden")
true //element with "display:inline", visible in browser, but yet it is hidden

您期望的不是“内联”,而是“无”,因为使用了 :hidden 过滤器。

它的作用是从对象数组中选择第一个隐藏元素。每次我调用这些代码行时,我希望它们选择下一个隐藏元素(而不是我刚刚显示的元素)。

With jQuery 1.4.2, :hidden filter is not filtering out elements that were hidden, but i've made then visible by calling show(). Filter assumes it is still hidden.

Is this bug or am i missing something? Consider the following code:

$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").css("display")
"none"
$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").show()
Object
$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").css("display")
"inline" // ?? Let me scratch my head...
$("td.ms-authoringcontrols > span[id*='_ParallelApprovers']:hidden:first").is(":hidden")
true //element with "display:inline", visible in browser, but yet it is hidden

Instead of "inline", you would expect "none", because :hidden filter was used.

What it does is from an array of objects it selects first hidden element. Each time i call these lines of code, i expect them to select next hidden element (not the one i just showed).

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

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

发布评论

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

评论(1

红玫瑰 2024-09-12 05:22:53

假设 .show() 线性发生,您的代码将是正确的。但是 .show() 启动一个动画,并以显示的对象结束。如果您想在代码显示后执行代码,请使用带有动画长度和回调 .show(100,function(){}) 的替代形式。

Your code would be correct assuming the .show() happened linearly. However .show() starts an animation that ends with the object being shown. If you would like to execute code after it has shown use the alternative form with a animation length and a callback .show(100,function(){}).

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