Answer the question
In order to leave comments, you need to log in
How to pass variable with jquery element class?
For example, I want to change class 2 color to green
<div id="1" class="2">yo</div>
I find the class by id and put it in the "my" variable, I want the color to change on click
var my = $('#1').attr('class');
$(my).click(function() {
$(my).css( "color", "green" )
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question