Change the color of Wishlist link when it is non-empty

A Merchant recently contacted us with a very specific requirement. They wanted the text color of wishlist link to be different when the wishlist was non-empty.

The default text color of wishlist link was #000. They wanted the text color to be changed to red when it was non-empty.

This is possible using Javascript. The trick here is to check if .topbadge class is non-empty and set the color to red. The code needs to be wrapped inside a callback function SWCallbackWishlistButtonLoaded

The below Javascript code achieves this.

var SWCallbackWishlistButtonLoaded=function(){
if (!$('.topbadge').is(':empty')) $("a[href='/a/wishlist']").css("color","red");

Leave a Reply

Your email address will not be published. Required fields are marked *