{"id":791,"date":"2012-06-05T19:32:39","date_gmt":"2012-06-05T19:32:39","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=791"},"modified":"2012-06-05T19:32:39","modified_gmt":"2012-06-05T19:32:39","slug":"jquery-check-for-jquery-check-for-hash-in-url","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-check-for-jquery-check-for-hash-in-url\/","title":{"rendered":"jquery check for # (Hash) in URL"},"content":{"rendered":"<p>Ever wanted to <em><strong>check if # (Hash) is present in URL, using jQuery<\/strong><\/em>? You can do that easily with few line of code.<!--more--><\/p>\n<h2>How to check for # (Hash) in URL using jQuery<\/h2>\n<p>Here is a very easy example.<\/p>\n<pre class=\"lang:xhtml decode:true\">&lt;script type=\"text\/javascript\"&gt;\n\n$(document).ready(function() {\n\nif(window.location.hash)\n{\n\/\/If # exists, do this.\n}\nelse\n{\n\/\/If # does not exist, do this.\n}\n\n});\n\n&lt;\/script&gt;<\/pre>\n<p><strong>Note:<\/strong><\/p>\n<p>The above code will trigger as soon as the page loads. So if you want it to trigger only when a button is clicked, you will need to bind it to the click event of the button.<\/p>\n<h5>Very simple, isn&#8217;t it?<\/h5>\n<p>Do you know of any other ways to <strong>check for # (Hash) in URL\u00a0using jQuery<\/strong>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever wanted to check if # (Hash) is present in URL, using jQuery? You can do that easily with few line of code.<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[41],"class_list":["post-791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-cL","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=791"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/791\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}