jQuery up and down sliding.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

jQuery up and down sliding.

Post by social_experiment »

I have a form that is hidden and will be displayed when clicking a link; i created jQuery for this and it's working. Now i want the option to hide the form again but with the current code i have the form is show, but then closed again when i click the link. Below is my jQuery code, how can i modify it to keep the form displayed but allow me to hide it by clicking on the same link?

Code: Select all

$(document).ready(function() {
$('form').hide();
//$('a.current').click(function() {
$('a.more').click(function() {
$('form').slideDown('slow');
//$(this).hide();
return false;
});
});
// ----
$(document).ready(function() {
	$('a.more').click(function() {
		$('form').slideUp('slow');
		return false;
	});
});
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Gopesh
Forum Contributor
Posts: 143
Joined: Fri Dec 24, 2010 12:48 am
Location: India

Re: jQuery up and down sliding.

Post by Gopesh »

Hi use slideToggle() method for it.
Check this Fiddle http://jsfiddle.net/nbAYb/.
Hope it works out.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: jQuery up and down sliding.

Post by social_experiment »

Thanks; it works perfectly :)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply