jquery – 具有id的div内的多个标签的选择器

在jQuery中,如何为#con中的标签h1,h2,h3和p构建选择器?

像$(‘#con h1,#con h2,#con h3,#con p’)但不重复#con

解决方法

您可以执行以下任何操作:
$("#con h1,#con p")   // your original

$("h1,h3,p",$("#con"))            // pass jQuery object in as context

$("h1,"#con")               // pass selector in as context

$("#con").find("h1,p")          // do what jQuery ultimately does 
                                         // in the end when passing context
                                         // as jQuery or as string selector

I’ve created a nice little jsFiddle that demos all of this.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...