Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


jQuery Control Appearance of Div and Slide up after Text Appears

Posted on 2011-03-08
Medium Priority
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: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_26866625.html

* Author:      Marco Kuiper (http://www.marcofolio.net/)

// 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" : "http://www.sxc.hu/photo/1271909",
		"firstline" : "Dubstep is a genre of electronic dance music",
		"secondline" : ""
	}, {
		"title" : "Office Appartments",
		"image" : "work.jpg",
		"url" : "http://www.sxc.hu/photo/1265695",
		"firstline" : "Or still busy at",
		"secondline" : "work?"
	}, {
		"title" : "",
		"image" : "biking.jpg",
		"url" : "http://www.sxc.hu/photo/1221065",
		"firstline" : "Get out and be",
		"secondline" : "active"
	}, {
		"title" : "",
		"image" : "nature.jpg",
		"url" : "http://www.sxc.hu/photo/1271915",
		"firstline" : "Take a fresh breath of",
		"secondline" : "nature"
	}, {
		"title" : "Italian pizza",
		"image" : "food.jpg",
		"url" : "http://www.sxc.hu/photo/1042413",
		"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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 15

Accepted Solution

SRigney earned 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In my daily work (mainly using ASP.net), 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 …
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

618 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