You have an unnecessary "n" in your code.

var test_css = {'background':'#000'};
$("ul li:nth-child(3n)").css(test_css);

should be
$("ul li:nth-child(3)").css(test_css);

Liam


huntspointer2009 wrote:
- Can someone please help me solve the following issue?
- How can I select and apply a 'background-color' to the following
<li></li> tags using JQuery?

<ul class="item_list">
<li></li>
<li></li>
<li></li><!-- I want to select this one -->
<li></li><!-- I want to select this one -->
<li></li>
<li></li>
<li></li><!-- I want to select this one -->
<li></li><!-- I want to select this one -->
<li></li>
<li></li>
<li></li><!-- I want to select this one -->
<li></li><!-- I want to select this one -->
<li></li>
<li></li>
<li></li><!-- I want to select this one -->
<li></li><!-- I want to select this one -->
<li></li>
<li></li>
</ul>


I've tried the following code, but it does NOT work:
var test_css = {'background':'#000'};
$("ul li:nth-child(3n)").css(test_css);


(Thank you, in advance)
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.421 / Virus Database: 270.14.20/2440 - Release Date: 10/16/09 06:32:00


Reply via email to