I just need a simple function that will search the current url for a string (ie “nature”) and then will add a class to an object. I keep finding ways to search the query, but I want to search the entire url. If possible, without jQuery. If not, jQuery will work.
Share
You can get the URL with
window.location.href, and search it however you like:window.locationreturns aLocationobject, which has a propertyhrefcontaining the entire URL of the page.