Switch/toggle div (jQuery)
Use this:
<script type="text/javascript" language="javascript">
$("#toggle").click(function() { $("#login-form, #recover-password").toggle(); });
</script>
Your HTML should look like:
<a id="toggle" href="javascript:void(0);">forgot password?</a>
<div id="login-form"></div>
<div id="recover-password" style="display:none;"></div>
Hey, all right! One line! I <3 jQuery.
This is how I toggle two div
s at the same time:
$('#login-form, #recover-password').toggle();
It works!
Since one div is initially hidden, you can simply call toggle for both divs:
<a href="javascript:void(0);" id="forgot-password">forgot password?</a>
<div id="login-form">login form</div>
<div id="recover-password" style="display:none;">recover password</div>
<script type="text/javascript">
$(function(){
$('#forgot-password').click(function(){
$('#login-form').toggle();
$('#recover-password').toggle();
});
});
</script>
I think you want this:
$('#recover-password').show();
or
$('#recover-password').toggle();
This is made possible by jQuery.