1.什么是jquery
- 首先我们学这个选择器需要具备逻辑能力,还有html/css/javascript的基础
- jquery 是一个框架库 封装了 原生js
- 优势:减少代码量 提高兼容性 (写的少做的多) 简单好学
- jquery可以链式操作 同一个对象多次操作(尽量避免写多个链式操作)
obj.html().css().text();
2.根据开发需求 随时调整库的版本
稳定版 1.9
完整版 压缩版
轻量级开发框架
3.学习
jquery 支持隐式迭代 (一次性操作一堆)
要写jquery代码 需要引入jquery的库,按照引入js的方式引入到网页
jquery代码的写法和原生js一致:
根据元素是否初始化 代码两种方案:
1).写在dom元素初始化之后
jquery框架里面的对象
jquery对象
1.强大的选择器
因为jquerydom元素获取 使用的css1-css3的选择器 来匹配元素
基本选择器:
#id
element
.class
*
selector1,selector2,selectorN
2.层级选择器
ancestor descendant
parent > child
prev + next
prev ~ siblings
3.筛选器
:first
:not(selector)
:even
:odd
:eq(index)
:gt(index)
:last
:lt(index)
:header
:animated
:focus
3.内容选择器
:contains(text)
:empty
:has(selector)
:parent
4.可见性选择器
:hidden
:visible
5.子元素选择器
:first-child
:first-of-type1.9+
:last-child
:last-of-type1.9+
:nth-child
:nth-last-child()1.9+
:nth-last-of-type()1.9+
:nth-of-type()1.9+
:only-child
:only-of-type1.9+
6.表单选择器
:input 匹配所有 input, textarea, select 和 button 元素
:text
:password
:radio
:checkbox
:submit
:image
:reset
:button
:file
7.表单对象属性
:enabled
:disabled
:checked radio checkbox
:selected 针对下拉选择
8.属性
[attribute]
[attribute=value]
[attribute!=value]
[attribute^=value]
[attribute$=value]
[attribute*=value]
[attrSel1][attrSel2][attrSelN]