Hey guys i'm trying to make jquery code to change the icon's class by selecting radio input that has the value of class but the problem is its add the class vale to all others icons class's
here my code: HTML
<div class="select-container">
<input type="radio" value="icon-home">
<input type="radio" value="icon-car">
<input type="radio" value="icon-sky">
<input type="radio" value="icon-color">
</div>
<div class="container-icons">
<a>
Home Icon: <i class="icon"></i> <button class="select"></button>
</a>
<a>
Car Icon: <i class="icon"></i> <button class="select"></button>
</a>
<a>
Sky Icon: <i class="icon"></i> <button class="select"></button>
</a>
<a>
color Icon: <i class="icon"></i> <button class="select"></button>
</a>
</div>
Jquery:
<script>
jQuery('body').on('click' , '.select' , function() {
jQuery('.select-container').show();
$('.select-container').on('change', function () {
var icon_value = $("input[type='radio'][name='icon']:checked").val();
$('.icon').addClass(icon_value);
});
});
</script>