JQuery选择器学习记录

mac2022-06-30  20

## 基本选择 $("p") //选择所有<p>元素 $("#demo") //选择所有id="demo"的元素 $(".demo") //选择有class="demo"的元素 ## 过滤选择 $("p.demo") //选择p下class="demo"的元素 $("p#demo") //选择p下id="demo"的元素 $("p:first") //选择第一个p元素 $("p:last") //选择最后一个p元素## 层叠选择器 $("div ul ul") //选择div内ul内的ul $("#demo > *") //选择id="demo"下的所有子元素关键是要灵活组合各种选择器

参考http://www.w3school.com.cn/jquery/jquery_ref_selectors.asp

转载于:https://www.cnblogs.com/diachan/p/6845858.html

相关资源:jQuery学习笔记之jQuery选择器的使用
最新回复(0)