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

Viewed 39

I'm trying to hide a form only if it's on the root site, or on the specific hash https://www.example.com/#uno. My code below is causing the form is not show on all the subpages (/#dos, /#tres, etc). Can someone help me understand what is happening?

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