I am trying to verify if the class of the "box" element contains the "current" class, but I am consistently receiving a false return.
<body>
<script>
var message = $(".box").hasClass("current");
console.log(message);
</script>
<div class="container">
<div class="box current"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
<button class="button">Click Me!</button>
</body>
I am seeking to obtain a true value or the index of the element that evaluates as true for the "current" class when checking the class of the "box" elements.
` (where it belongs) or wrap it in doc.ready `$(() => { ..your code .. })`
– freedomn-m Jan 17 '23 at 18:02