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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery get each value 2 31
how can i select 4 29
where is team.js? 3 24
Hide cell in a table 2 10
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

776 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