jQuery学习笔记2
筛选:是一些方法,与选择器的功能差不多,都是为了查找个体
1.过滤
- eq(i),筛选索引值为i的元素,例如
$('h1').eq(0).css({'color':'#00f'});
- not(),筛选除了特定元素的其他元素,例如
$('h1').not($('h1').eq(0).css({'color':'#00f'}));
- first()和last()
- slice(i,j)或者slice(i),筛选第i个到第j个,或者第i个到最后一个
2.查找
- children()
- find(),找到子孙后代里面满足特定要求的元素
- next()
- nextAll()
- parent()
- prev()
- prevAll()
- siblings(),前后所有的兄弟节点
3.串联
- add(),功能跟组合选择器一样,例如
$('h1').add('p').css({'color':'#00f'});
- andSelf(),功能是串联回自己,例如
$('div').next().andSelf().css({'color':'#00f'});