Jump to content

add a css class to a URL with Jquery

Recommended Posts

Posted

Site URL: http://www.thevisualpharmacy.com

Hey All,

 

I have a custom button that I have created for my products page that links off to an external site for people to purchase from. 
I have hidden the original purchase button and I am styling the new link using CSS to target the link. 

I am now trying to add a class to the URL Link using JQuery but I can't seem to get it right. I stumbled upon this code snippet here but upon using inspect element It doesn't show that the class has been added.
 

    $(function(){
        var cUrl = window.location.href;
         $("a").each(function(){
                 if ($(this).attr("thevisualpharmacy.gumroad.com/l/nintendo64mockup") == cUrl){
                         $(this).addClass(“gumroad-button”-);
                 }
         });
    });


I have loaded the JQuery Library, I am not an expert at JQuery by any means. Any insight to this is helpful. Thank you guys.

  • Replies 1
  • Views 600
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.