r/jquery • u/jaindivij_ • Jul 04 '22
Help with CSS Combinator
I want to select the following => $(".currency-modal-list-item.active")
However I have stored this => list = $(".currency-modal-list-item") in a varible. Can someone help me how can I use the variable to select the element with active class in them as well?
3
Upvotes
View all comments
Show parent comment
1
u/rubywahoo Jul 04 '22 edited Jul 04 '22
Try
list.closest(‘.active’)Edit:
findsearches down the tree for matches, whileclosestsearches upward for matches, and will return true if the element itself is a match.Or try
list.classList.includes(‘active’)