How to add class “bottom-post” to the post that is at the very bottom of my wordpress blogroll? I need to style it differently. (I can’t use the static ID since the the post and the total number of posts are constantly changing)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can add classes to elements with jQuery:
and then style like so:
A benefit of this method (compared to using pure css) is that this will apply the class to the element and allow styling even on browsers that don’t support the
:last-childcss selector. I tested this on IE6-8 and it worked in all of them.The following provides an explanation as to why the
:last-childpsuedo selector tends to be preferred over:lastin this case:http://api.jquery.com/last-selector/