 <p>There's several ways, but this is the simplest given what you are doing:</p> <pre><code>$(document).on("click", "ul.form-nav a", function(event) { event.preventDefault(); var id = event.target.href.replace(/^[^#]+/, ""); console.log("Going to: " + id); // Hide forms that do not have the selected id $('form.hidden').not(id).hide(); // Show the appropriate form $(id).show().focus(); }); </code></pre> <p>View the <a href="http://jsfiddle.net/mMyLW/" rel="nofollow">Fiddle</a></p>