1、jQuery版本
jQuery版本有1.x,2.x,3.x,推荐使用1.x的最新版本,因为兼容性好,可兼容IE6/7/8。
下载地址:https://www.jb51.net/zt/jquerydown.htm
当前1.x最新的版本为1.12,完整版:
http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.12.4.js
压缩版:
http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.12.4.min.js
jQuery和Dom对象转换
jQuery对象[0] => Dom对象
Dom对象 => $(Dom对象)
选择器,直接找到某个或者某类标签
1. id
$('#id')
2. class
<div class='c1'></div>
$(".c1")
3. 标签
<div id='i10' class='c1'>
<a>f</a>
<a>f</a>
</div>
<div class='c1'>
<a>f</a>
</div>
<div class='c1'>
<div class='c2'> </div>
</div>
$('a')
4. 组合a
<div id='i10' class='c1'>
<a>f</a>
<a>f</a>
</div>
<div class='c1'>
<a>f</a>
</div>
<div class='c1'>
<div class='c2'> </div>
</div>
$('a')
$('.c2')
$('a,.c2,#i10')
5. 层级
$('#i10 a') 子子孙孙
$('#i10>a') 儿子
6. 基本
:first 第一个标签
:last 最后一个标签
:eq(index) 根据索引找
7. 属性
$('[alex]') 具有alex属性的所有标签
$('[alex="123"]') alex属性等于123的标签
<input type='text'/>
<input type='text'/>
<input type='file'/>
<input type='password'/>
$("input[type='text']")
$(':text') 通过表单属性直接找到标签
以上为基本的一些选择器查找方式,详细的可至以下网址查看:
https://jquery.cuishifeng.cn/