javascript - How to hide an element only if it matches specific hash? -


i'm trying hide form if it's on root site, or on specific hash https://www.example.com/#uno. code below causing form not show on subpages (/#dos, /#tres, etc). can me understand happening?

$(function(){     if (location.hash == "" || location.hash == "#uno"){       $("#form").hide();     } else {       $("#form").show();     }; }()); 

this because hide form once, don't make reappear until reload page. (you check hash once, when loading entire page, not when hash changes.

function showhideform() {     if (location.hash == "" || location.hash == "#uno"){         $("#form").hide();     } else {         $("#form").show();     }; }  window.onhashchange = showhideform; 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -