I have a div as follows:
<DIV CLASS="variable productPopup"></DIV>
When assigning it to a var, how do I only select variable? Please note that variable changes, so it needs to select the first item, not literally the words "variable"
var ID = $(this).attr("class");
To get the first class mentioned, you can split the value by spaces:
var firstClass = $(this).attr("class").split(" ")[0];
So if the class attribute was "foo Bar", you'd get "foo".
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