Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-10-2009, 10:29 PM   PM User | #1
johnfizgerts
New to the CF scene

 
Join Date: Jul 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
johnfizgerts is an unknown quantity at this point
Arrow jQuery: Content Animator (show/hide/change)

Hey,

I'm working on a script that uses a function (called on click) to change the content of a div (called description) within the page. It contains an unordered list and list items. The first one has the class "show" and the ID "1", the second with just the ID "2", and so forth. (see code below).

I am using jQuery to control the onclick function. the jQuery gets the current object with the "show" class. If there is no show class, it takes the first. It then puts a variable string together that represents the UL LI that is needed to be shown.

Code:
var descurrent = ($('div#description ul li.show')?  $('div#description ul li.show') : $('div#description ul li:first'));
var desclass = '#description li#'+x;
Note: x is a variable transfered from the function change(x); where x is the ID that is to be shown

HTML CODE:
Code:
<div id="description">
					<ul>
						<li class="show" id="1">blahblah
						</li>
						<li id="2">
etc
						</li>
					</ul>
The jQuery i'm trying to get to work is:
Code:
//Hide the current image
		descurrent.animate({opacity: 0.0}, 1000)
		.removeClass('show');
	
		//Show new image
		
		$(desclass).addClass('show')
		.animate({opacity: 1.0}, 1000);
Note: the class "show" has a higer z-index

So basically what I'm having trouble with is hiding one div, and showing another in the same place. From testing it looks like the removeClass and descurrent animate functions are working, but the desclass.addClass isnt. Please help
Thanks in advance,
Hope this can be resolved soon, been giving me headaches!
Cheers,
John
johnfizgerts is offline   Reply With Quote
Reply

Bookmarks

Tags
animator, change content, content, jquery

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:22 PM.


Advertisement
Log in to turn off these ads.