How do I get the class name through JavaScript given no id with this span.
span
Like:
I want to
You can use a jquery to solve the same issue.
var classname = $(this).attr('class'); //here you will get current class name if its with multiple class split it and take first class. $("."+classname.split(" ")[0]).css("background-color", "yellow");