ID为div的多个标签的选择器 [英] Selector for multiple tags inside a div with id
本文介绍了ID为div的多个标签的选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在jQuery中,如何在#con内为标签h1,h2,h3和p构建选择器?
In jQuery, how can I build a selector for tags h1, h2, h3 and p inside #con?
类似于$('#con h1, #con h2, #con h3, #con p')
,但无需重复#con
推荐答案
您可以执行以下任一操作:
You can do any of the following:
$("#con h1, #con h2, #con h3, #con p") // your original
$("h1, h2, h3, p", $("#con")) // pass jQuery object in as context
$("h1, h2, h3, p", "#con") // pass selector in as context
$("#con").find("h1, h2, h3, p") // do what jQuery ultimately does
// in the end when passing context
// as jQuery or as string selector
这篇关于ID为div的多个标签的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文