Take the tough here!
I am creating a blogger template and the client wants different colors to be applied to the headings in the right column of the template.
The problem is that I have little control over the html created, as it is controlled by the blogger engine.
I want to be able to:
Select the nth instance of the h2 element with the "title" class and apply the CSS style using jQuery.
The limiting factor is that it seems that Jquery wants you to tell it what the parent element is, so that it can count the elements. However, in this design, an element can appear anywhere, and this is the number of instances for the entire page that interests me. Correct me if I am wrong here.
I tried the following code without success - trying to use the indirect CSS decryption selector:
$(document).ready(function () {
alert('test');
$("#RightColContent S+ h2.title:nth-child(2)").css('background-color', 'green');
$("#RightColContent S+ h2.title:nth-child(3)").css('background-color', 'red');
});
This code applied the style, but to all elements, apparently because I did not provide a parent element:
$("h2.title:nth-child(1)").css('background-color', 'green');
Please see the html firebog inspection image to see the html stream.
alt text http://bombdefused.com/firebug.png
Kudos to anyone who can help me.
source
share