jquery筛选器
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <title>jquery筛选器</title> <meta charset="UTF-8"> <script src="jquery-3.4.1.js"></script></head><body><div class="div1">h 1 <div div="div8">hello 8</div> <div div="div9">hello 9</div> <div div="div10">hello 10</div> <div class="div2">h 2 <div class="div3"> h 3 </div> </div> <div div="div4">hello 4</div> <div div="div5">hello 5</div> <div div="div6">hello 6</div> <div div="div7">hello 7</div></div><p>h 4</p><div class="div"> <ul> <li class="text">111</li> <li>222</li> <li>333</li> <li>444</li> <li>555</li> </ul></div><script> //二.jquery筛选器 //(一).过滤筛选器// 1.$(‘li‘).eq(2).css(‘color‘,‘red‘); // 2. $(‘li‘).first().css(‘color‘,‘red‘); //3.alert($(‘ul li‘).hasClass(‘test‘));//question //(二)查找筛选器 //1.// $(‘.div1‘).children().css(‘color‘,‘red‘);//只找儿子辈,自己不找// $(‘.div1‘).find(‘.div3‘).css(‘color‘,‘red‘);//后代都找 //2.// $(‘.div2‘).next().css(‘color‘,‘red‘);// $(‘.div2‘).nextAll().css(‘color‘,‘red‘);// $(‘.div2‘).nextUntil(‘.div6‘).css(‘color‘,‘red‘);不生效 //3.// $(‘.div2‘).prev().css(‘color‘,‘red‘);// $(‘.div2‘).prevAll().css(‘color‘,‘red‘);// $(‘.div2‘).prevUntil(‘.div9‘).css(‘color‘,‘red‘);不生效 //4.// $(‘.div2‘).parent().css(‘color‘,‘red‘);// $(‘.div2‘).parents().css(‘color‘,‘red‘);// $(‘.div3‘).parentsUntil(‘.div1‘).css(‘color‘,‘red‘);// $(‘.div3‘).parentsUntil(‘body‘).css(‘color‘,‘red‘); //5. $(‘.div2‘).siblings().css(‘color‘,‘red‘);</script></body></html>
相关推荐
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08
82550495 2020-08-03
tthappyer 2020-08-03
84901334 2020-07-28
tthappyer 2020-07-25
TONIYH 2020-07-22
tztzyzyz 2020-07-20
83510998 2020-07-18
81463166 2020-07-17