JQuery 选择器逻辑“与”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5234462/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 18:47:21  来源:igfitidea点击:

JQuery selector logical "and"

jquery

提问by Mandoleen

How can I access elements that have name Xand type hidden?

如何访问具有 nameX和 type 的元素hidden

回答by Amir Raminfar

You should try this if you want type=hidden

如果你愿意,你应该试试这个 type=hidden

$('input[name="X"][type="hidden"]')

If you want an element that is hidden via css then you should try

如果你想要一个通过 css 隐藏的元素,那么你应该尝试

$('[name="X"]:hidden')

回答by StuperUser

回答by Surreal Dreams

$('[name="X"]:hidden').dosomething();

This will select an element with a name="X"attribute which is hidden. You can learn lots more about jQuery selectors- there's plenty of useful help there.

这将选择具有name="X"隐藏属性的元素。您可以了解有关jQuery 选择器的更多信息- 那里有很多有用的帮助。