Jump to content

add a css class to a URL with Jquery

Recommended Posts

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.

Link to comment
  • Replies 1
  • Views 520
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • 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.