Using JQuery, how do you check if an element’s previous sibling is the first-child?
I have tried the following code but it does not work:
if( $(this).prev() === $(this).siblings(":first-child") ){
//do something
}
An example using the above === approach: http://jsfiddle.net/xnHfM/
demo http://jsfiddle.net/p7sAq/
p.s. I’ll try to see the perf about this solution vs .is(‘:first-child’) => http://jsperf.com/jquery-check-previous-first-child
edit : see last comment, thanks @RightSaidFred 🙂