[英]jquery :nth-child() class is not working
這不起作用
$(".text_read:nth-child(2)").css("background", "transparent url('images/text_read2.png') no-repeat");
上面的代碼的結果與下面的代碼相同
$(".text_read").css("background", "transparent url('images/text_read2.png') no-repeat");
我的HTML代碼是
<div class="welcome">
<p class="welcometext">MORE UPCOMING NEWS FOR INTERNATIONAL EVENTS</p>
<div class="all_international_img row-fluid">
<div class="welcome-image span4 international_img">
<img src="images/img1.png">
<div class="text_read">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a </div>
</div><!--all_international_img row-fluid-->
<div class="welcome-image span4 international_img">
<img src="images/img1.png">
<div class="text_read">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a </div>
</div><!--all_international_img row-fluid-->
<div class="welcome-image span4 international_img">
<img src="images/img1.png">
<div class="text_read">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a </div>
</div><!--all_international_img row-fluid-->
</div><!--all_international_img-->
</div><!--welcome-->
您可以使用Eq來獲取子元素
$('.text_read).eq(0);
你可以試試這個。
$(".text_read").eq(2).css({"background", "transparent url('images/text_read2.png') no-repeat"});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.