hi! I would like to know how to use jquery in sliding left to right?

Can you give me simple sample there..

thanks in advance.

Recommended Answers

All 6 Replies

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

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

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.

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

no problem, let me know if you have any more questions.

sorry for late reply. Now! i really know how to use it. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.