2
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by canterorist
0

the slide function in jQuery won't allow you to slide horizontally, only veritcally.. to slide horizontally you must use the animate function

let's say you have a link and when you click it you want an image that is a child of the <a> tag to toggle slide.. here is how you would code it

$(function(){
	$('a').click(function(){
		$(this).find('img').slideToggle();
	});
});

since you can't have two functions on click you have to put slideToggle which is the same as slideDown and slideUp but in one fuction....

here is a link to a blog post i wrote that will help you make a dropdown menu using slideDown and slideUp on hover

blog post

hope this'll help you

Edited by bvelez352: n/a

0

thanks bvelez352 for your sample code. I really appreciate it, but do you have sample code in animate function?
thanks in advance

0

Sure.

Let's say you have a div that when you click a link you want the width to toggle from 0 to 150px with an animate function

here

$(function(){
	$('div.divClass').css({
		'width':'0'
	});
	$('a.className').toggle(function(){
		$('div.divClass').animate({
			'width':'150px'
		});
	});
});

i wrote this from the top of my head, so if you get any problem, let me know.

0

thank you bvelez352 for your time in giving me a sample code. I will try this at home.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.