Answer the question
In order to leave comments, you need to log in
How to get clicked jquery object?
For example, there are two blocks with the same id
<div id="1" class="one">yo</div>
<div id="1" class="two">me</div>
$('#1').click(function(event) {
var myClass = $( event.target ).attr('class');
$('.' + myClass).css( "color", "green" );
}
Answer the question
In order to leave comments, you need to log in
The ID must necessarily begin with a Latin character and can contain Latin letters (A–Z, a–z), numbers (0–9), hyphens (-), and underscores (_).
The ID in the document code must be in a single copy .
You can use the generic on method
$(".sort a").on("click", function() {
//...
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question