Jump to content

help with slider


CyberShot

Recommended Posts

i need help with my code. I made a very very simple slider that does work. Here is the code

 

$("#headerBottom p").hide();
$("#logo").hide();

$("#headerBottom p:eq(4)").show();
$("#content span").hide();				 
    $("#content span:eq(0)").show();

$("#topLogo").click(function(){
	$("#content span").hide();
	$("#headerBottom p").hide();
	$("#content span:eq(0)").show();
	$("#headerBottom p:eq(4)").show();
 });

   $("#aboutPage").click(function(){
	if($("#content span:eq(1)").is(':visible'))
	{
		$("#aboutPage").show();
	} else {
	$("#headerBottom p:eq(4)").hide();
	$("#content span").slideUp();
	$("#content span:eq(1)").slideDown(); 
	$("#headerBottom p").hide();
	$("#headerBottom p:eq(0)").show();
	}
 });
   
   $("#workPage").click(function(){
	if($("#content span:eq(2)").is(':visible'))
	{
		$("#workPage").show();
	} else {
	$("#content span").slideUp();
	$("#content span:eq(2)").slideDown();
	$("#headerBottom p").hide();
	$("#headerBottom p:eq(1)").show();
	}
 });

$("#socialPage").click(function(){
	if($("#content span:eq(3)").is(':visible'))
	{
		$("#aboutPage").show();
	} else {
	$("#content span").slideUp();
	$("#content span:eq(3)").slideDown();
	$("#headerBottom p").hide();
	$("#headerBottom p:eq(2)").show();
	}
 });

$("#contactPage").click(function(){
	if($("#content span:eq(4)").is(':visible'))
	{
		$("#contactPage").show();
	} else {

	$("#content span").slideUp();
	$("#content span:eq(4)").slideDown();
	$("#headerBottom p").hide();
	$("#headerBottom p:eq(3)").show();
	}
 });
});


my issue is that I am using the span tag as a hook. To say in the code...Find all span tags and hide their content. But the problem is that the span tag is an inline element and I am running into validation problems using a block element inside an inline element. So I need to re work this code. I thought instead. Maybe I could put my 4 divs into an array and call them that way or seperately. something like

var contentDiv = array [#about, #work, #social, #contact];

so then in my jquery above, instead of saying ("#content span").slideUp(); 

I could do ("contentDiv").slideUp();
("contentDiv:eq(1)").slideDown();

but not sure how to make the array. can you help

Link to comment
Share on other sites

I am getting a syntax error, this is my test code

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="js/jquery.js"></script>

<script type="text/javascript">
$(docuemtn).ready(function(){
var contentDiv = array ['about', 'work', 'social', 'contact'];

$.each(contentDiv. function(){  
$('#'+this+':eq(0)).hide();  
$('#'+this+':eq(1)).slideDown();
});

</script>

<style type="text/css">
#about {
width: 100px; height: 100px;
}

#work {
width: 100px; height: 100px;
}
#social {
width: 100px; height: 100px;
}
#contact {
width: 100px; height: 100px;
}
</style>
</head>

<body>

<div id="about">
about
</div>

<div id="work">
work
</div>

<div id="social">
social
</div>

<div id="contact">
contact
</div>
</body>
</html>

Link to comment
Share on other sites

ok, fixed that and also noticed that the funciton wasn't closed with the }); but still something is wrong

 

$(docuemtn).ready(function(){
var contentDiv = array ['about', 'work', 'social', 'contact'];

$.each(contentDiv .function(){  
$('#'+this+':eq(0)').hide();  
$('#'+this+':eq(1)').slideDown();
						});
					   });

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.