Blogger Information
Blog 26
fans 0
comment 1
visits 18613
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP课程第十三天 JQuery常用选择器
Sam徐民强的博客
Original
537 people have browsed it

Jquery 常用选择器

1、eq()返回指定的索引元素 ,返回的是Jquery对象

   $('li').eq(2).class('color','#fff000')

2、find()返回所有的元素

  $('li').find('a').class('color','#fff000')

3、children()返回所有的直接子元素

  $('li').children('span').class('color','#fff000')

4、frist()返回第一个元素

  $('li').frist().class('color','#fff000')

5、last()返回第最后一个元素

  $('li').last().class('color','#fff000')

6、清楚li的所有内嵌样式

   $('li').removeAttr('style')

7、清楚div的所有内嵌样式

  $('div').removeClass()

8、为元素添加样式 

  $('li a').addClass('green')

  $('ul>*').addClass('red') 为ul下面的所有子元素添加样式

9、toArray(),返回数组,不是jquery对象

var li = $('li').toArray()    

for(var i=0; i<li.length; i++){    

li[i].style.color = '#fff000'    

}    


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