Blogger Information
Blog 30
fans 2
comment 3
visits 20301
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jquery的常用选择器函数——2018年4月3日
jackallen的博客
Original
493 people have browsed it

一、常用选择器函数

首先引入js

<script src="../js/jquery-3.3.1.js"></script>

<script type="text/javascript">

//获取li中第一个元素,将前景色设置为绿色

1.$('li').get(0).style.color = 'green'

//获取li中序号是第一个的元素

2.$('li').eq(1).css('color','blue')

获取第一个返回的元素()里不填写参数

3.$('li').first().css('color','blue')

获取最后一个元素()里不填参数

4.$('li').last().css('color','#68686868')

查找元素,返回所有后代元素

$('ul').find('a').css('color','#000')

返回所有的直接元素

5.$('li').children('p').css('color','#808080')

元素遍历

$('li').eq(2).next.css('color','red')

</script>

Correction status:qualified

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