I just wrote this code but I can't find a way to make it cleaner:
$(".graphic").click(function() {
$(".graphic i").toggleClass("fa-minus-square");
});
$(".web").click(function() {
$(".web i").toggleClass("fa-minus-square");
});
HTML:
<button class="btn graphic"><i class="fa fa-plus-square" aria-hidden="true"></i>Graphic designer</button>
<button class="btn web"><i class="fa fa-plus-square" aria-hidden="true"></i>Graphic designer</button>
I wanted something like the code below, but preventing those buttons from changing at the same time:
$(".btn").click(function() {
$(".btn i").toggleClass("fa-minus-square");
});
$(this)
inside theclick
callback.$(this).find('i').toggleClass('fa-minus-square');
or$('i', this).toggleClass('fa-minus-square');
– Tushar Oct 4 at 3:27