Reputation: 1
I have some svg's I want to change their fill on click, but I want it only change the color, on the one that I click, each svg have the same class and id's, but are in different divs/boxes
$('svg').on("click", function() {
$('.cls-1').css("fill","#8b5a0b");
});
Upvotes: 0
Views: 16
Reputation: 1333
You can use $(this)
inside event handler to get the element on which the event was fired.
$('svg').on('click', function() {
$(this).css('fill', '#8b5a0b');
});
Upvotes: 1