$(function(){ var url = location.href; var home = "http://www.example.com/"; if (url == home) { $('.test').hide(); } else if (url.match("page")) { $('.test').show(); } });