Blogger Information
Blog 15
fans 0
comment 1
visits 15002
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jquery属性选择器
空城的博客
Original
1952 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jquery属性选择器</title>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

    <script>
        //$('input[属性名]')       选择含有某个属性值的元素
        //$('input[attr=value]')  选择属性值等于某个值的元素
        //$('input[attr!=value]') 选择属性值不等于某个值的元素
        //$('input[attr^=value]') 选择属性值开头等于某个值的元素
        //$('input[attr$=value]') 选择属性值结尾等于某个值的元素
        //$('input[attr*=value]') 选择属性值结尾等于某个值的元素
        //$('attSel[1] attSel[2] attSel[3]') 多重选择器,要求同时满足才能选择上

        $(document).ready(function(){
            $('input[type]').css('background','red');
            $('input[type=password]').css('background','blue');
            $('input[name!=hhe]').css('background','#ccc');
            $('input[name^=t]').css('background','pink');
            $('input[name$=e]').css('background','black');
            $('input[type*=pa]').css('background','green');
            $('input[type*=pa] input[name*=hhh]').css('background','gray');
        })
    </script>
</head>
<body>
    <form action="">
        <input type="text" name="hhe"><br/>
        <input type="password" name="thja"><br/>
        <input type="password" name="hhh"><br/>
        <input ><br/>
        <input type="text"><br/>
    </form>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!