Is there a way in jQuery to return the nearest sibling() div and check for a present class?
I have a visual verticle list of items, in which some items either have a 1px border (to set them apart - premium items) or no border at all (standard items). While it looks great when a premium item is sandwiched between two standard items, when two or three premium items stack up the borders between them end up being 2px thick.
I'm looking for a way, using jQuery or otherwise, to check if the <div class="item"> above the current div has the class featured-item (so checking if the div equals <div class="item featured-item">). From there, I will set another class name to set border-top to 0px and make the visuals flow a little better.
Can anyone help me out? Sorry if this question is convoluted, hard to explain!
if ($("#current-div").prev().hasClass("someClass")) {
// logic here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With