check each LI has a class "selected"
Hi,
I have a UL LI
- <ul class="selections">
- <li class="check-option ok selected">
- <div class="selections-text">Ok</div>
- <div class="selections-icon"><img src="/img/icons/check-tick.png" class="check-icon"></div>
- </li>
- <li class="check-option">
- <div class="selections-text">Advisory</div>
- <div class="selections-icon"><img src="/img/icons/check-circle.png" class="check-icon"></div>
- </li>
- <li class="check-option">
- <div class="selections-text">Defect</div>
- <div class="selections-icon"><img src="/img/icons/check-cross.png" class="check-icon"></div>
- </li>
- </ul>
I would like to check for each .
check-option to see if it hasClass(.selected)
here is my code I have tried so far which I don't think is quite right:
$(".check-option").each(function() {
if($(this).hasClass("selected")) {
console.log("has been selected");
return false;
} else {
console.log("has NOT been selected");
return false;
}
});
Please help?