Blogger Information
Blog 15
fans 0
comment 1
visits 15071
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jquery内容选择器
空城的博客
Original
1248 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>
    <style>
        div{
            width: 90px;
            height: 90px;
            margin-top:20px; 
            background: gray;
        }
    </style>
    <script>
        //1、$(selector:contains(text))  查找contains表示包含某一文本的选择器
        //2、$(selector:has(selector))   查找contains表示包含某一元素的选择器
        //2、$(selector:empty)           查找contains表示不含有任何内容的选择器 注意包含空元素的匹配不到
        //2、$(selector:parent)          查找contains表示包含子元素或文本的选择器
        $(document).ready(function(){
            $('div:contains("jion")').css("background","red");
            $('div:has(b)').css("background",'yellow');
            $('div:empty').css("background","blue");
            $('div:empty').css("background","blue");
            $('div:parent').css("background","pink");
        })
    </script>
</head>
<body>
    <div>jack</div>
    <div>jun</div>
    <div>jack cheng</div>
    <div>jion</div>
    <div><b>jion</b></div>
    <div></div>
    
</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