jQuery Control Appearance of Div and Slide up after Text Appears

Posted on 2011-03-08
Last Modified: 2012-05-11
Hi all,

I would like to add an effect to two elements, one is for my text, how do I modify the code below so that there is a slide from left to right?

and I would like to create to slide a colored background, div from bottom to up and show a link, the link part I got figured out as it's the title within var photos = [ { that turns into a link, but how do I add now a background with a width of 930px and and a height of 50px slide up and a link appears? but this almost must be done first and then only show the text.

See my previous answered post as it's modifying the same code:

* Author:      Marco Kuiper (

// Speed of the automatic slideshow
var slideshowSpeed = 6000;

// Variable to store the images we need to set as background
// which also includes some text and url's.
var photos = [ {
		"title" : "Stairs",
		"image" : "vacation.jpg",
		"url" : "",
		"firstline" : "Dubstep is a genre of electronic dance music",
		"secondline" : ""
	}, {
		"title" : "Office Appartments",
		"image" : "work.jpg",
		"url" : "",
		"firstline" : "Or still busy at",
		"secondline" : "work?"
	}, {
		"title" : "",
		"image" : "biking.jpg",
		"url" : "",
		"firstline" : "Get out and be",
		"secondline" : "active"
	}, {
		"title" : "",
		"image" : "nature.jpg",
		"url" : "",
		"firstline" : "Take a fresh breath of",
		"secondline" : "nature"
	}, {
		"title" : "Italian pizza",
		"image" : "food.jpg",
		"url" : "",
		"firstline" : "Enjoy some delicious",
		"secondline" : "food"

$(document).ready(function() {
	// Backwards navigation
	$("#back").click(function() {
	// Forward navigation
	$("#next").click(function() {
	var interval;
	}, function() {
		// Change the background image to "pause"
		$(this).css({ "background-image" : "url(images/btn_pause.png)" });
		// Show the next image
		// Start playing the animation
		interval = setInterval(function() {
		}, slideshowSpeed);
	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		// Check if no animation is running. If it is, prevent the action
		if(animating) {
		// Check which current image we need to show
		if(direction == "next") {
			if(currentImg == photos.length + 1) {
				currentImg = 1;
		} else {
			if(currentImg == 0) {
				currentImg = photos.length;
		// Check which container we need to use
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
		// Make sure the new container is always on the background
		// Set the background image of the new active container
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(images/" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		// Hide the header text
		$("#headertxt").css({"display" : "none"});
		// Set the new header text
			.attr("href", photoObject.url)
			.attr("href", photoObject.url)
		// Fade out the current container
		// and display the header text when animation is complete
		$("#headerimg" + currentContainer) .toggle('slow', function() {
			setTimeout(function() {
				$("#headertxt").css({"display" : "block"});
				animating = false;
			}, 2000);
	var stopAnimation = function() {
		// Change the background image to "play"
		$("#control").css({ "background-image" : "url(images/btn_play.png)" });
		// Clear the interval
	// We should statically set the first image
	// Start playing the animation
	interval = setInterval(function() {
	}, slideshowSpeed);

Open in new window

Question by:VAN_AL
  • 2
  • 2
LVL 15

Accepted Solution

SRigney earned 500 total points
ID: 35085633
You can probably use the Animate method from jQuery and the Comlete method. Once the animation is complete you could inject the link into the div at that point so the slide happens completely before the text appears.

Author Comment

ID: 35211336
I've tried that, I can't modify the above code to get that feature working.

Author Closing Comment

ID: 35236558
Now what I was looking for and found the answer somewhere else.
LVL 15

Expert Comment

ID: 35237742
I'm sorry the answer wasn't what you were looking for, you can request the question be deleted.  If you are going to leave it here, please post your answer so someone else with your problem can find the answer.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now