I have some jQuery/JavaScript code that I want to run only when there is a hash (#) anchor link in a URL. How can you check for this character using JavaScript?
#
Have you tried this?
if (url.indexOf('#') !== -1) { // Url contains a # }
(Where url is the URL you want to check, obviously.)
url