How to split the attribute “class” name in the html element
HTML :
<div id=”divUserDetails” class=”red”>
JQEURY :
$(document).on(“click”, “#divUserDetails”, function()
{
var userColor = $(this).attr(‘class’) == null ? “No User Color Found” : $(this).attr(‘class’);
alert(userColor );
}
Output
Here is the output
Leave A Comment