Blogger Information
Blog 32
fans 0
comment 0
visits 23738
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
常用选择器及JQ与DOM转换-2019年5月20日21点00分
小李广花荣
Original
673 people have browsed it
  1. 下面将展示代码及效果图


  2. 实例

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <script src="static/js/jquery-3.4.1.js"></script>
    </head>
    <body>
    <ul>
        <li>item1</li>
        <li>item2</li>
        <li>item3</li>
        <li>item4</li>
        <li>item5</li>
    </ul>
    <p>Hello Word</p>
    <div>
        你好,PHP
    </div>
    <script>
    
        $('p').css('color','red');
        $('ul:has(li)').css('color','red');
        $('li').eq(3).css('color','white');
        $('li:first-child').css('color','pink');
        $('ul:nth-child(1)').css('color','black');
        $('div:nth-of-type(1)').css('color','red');
    
        $('ul li:nth-of-type(3)').css('color','pink');
    
        //转DOM对象
    
        var list=$('li');
        console.log(list);
        console.log(list[2]);
        console.log(list.get());
    
    </script>
    </body>
    </html>

    运行实例 »

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

    QQ图片20190529174452.pngQQ图片20190529174517.png
  3. 本文学到JQuery文件得引入 

    如何使用选择器$('p');

    常用得选择器 nth-of-type(); nth-child();等

Correction status:Uncorrected

Teacher's comments:
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!