jQuery选择器

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/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值