I am struggling with changing the color of a specific anchor tag when clicked inside a div with class .product_wishlist. Currently, all anchor tags within .pw div are changing colors. Is there a way to apply selected css only to the clicked element? Any help would be greatly appreciated.
$(document).ready(function() {
$(document).on('click','.pw',function(e){
$('.pw > a').css('background-color', 'green');
});
});
.product_wishlist > a {
background-color: #e91e63;
height: 30px;
position: absolute;
right: -32px;
text-align: center;
top: 15px;
width: 30px;
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
z-index: 9;
}
.wishlish-selected > a {
background-color: black;
height: 30px;
position: absolute;
right: -32px;
text-align: center;
top: 15px;
width: 30px;
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
z-index: 9;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div class="product_wishlist pw">
<a href="#" target="_blank"><i class="ti-heart"></i>Wishlist</a>
</div>