can't get .indexOf to return expected value
This question was asked, and I would like to include additional info for the solution.
Original post:
I'm trying to select all elements that has a class that starts with "col-md", but no matter what I do .indexOf("col-md") returns -1.
Html:
- <div class="col-md-4">
- Test 1
- </div>
- <div class="col-md-8">
- Test 2
- </div>
jQuery:
- if ($col.attr("class").indexOf("col-" + val.toLowerCase()) > -1) {
- console.log($col);
- }
val is "MD"
Original post ends here
----------------------------------------------------------------------------------
also here is a jsfiddle:
Jim