2

这是行不通的

$(".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-->
4

4 回答 4

3

看起来你想.eq()改用

$('.text_read:eq(2)')

演示

于 2013-09-12T08:35:36.387 回答
2

改为:nth.eq()

演示

$('.text_read:nth(2)');
于 2013-09-12T08:38:08.253 回答
1

您可以使用 Eq 获取子元素

$('.text_read).eq(0);
于 2013-09-12T08:36:55.173 回答
1

你可以试试这个。

$(".text_read").eq(2).css({"background", "transparent url('images/text_read2.png') no-repeat"});
于 2013-09-12T08:38:19.773 回答