Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Search Search
Search for:
Tech Support Guy > > >

show/hide different div ID's


(!)

mwdesign's Avatar
mwdesign mwdesign is offline
Computer Specs
Member with 183 posts.
THREAD STARTER
 
Join Date: Aug 2010
Experience: Intermediate
23-Jul-2012, 07:40 AM #1
show/hide different div ID's
Hi, I posted this problem a little while ago about how i would adapt some jquery in order to target div ID's rather than a class which at the moment controls all my divs.

My ids are: #post1, #post2, #post3, all with different heights because of content.

here is my jquery:

Code:
// Set the initial height
var sliderHeight = "45px";

$(document).ready(function(){
	// Show the slider content
	$('.slider').show();

	
	$('.slider').each(function () {
		var current = $(this);
		current.attr("box_h", current.height());
	});
	
	$(".slider").css("height", sliderHeight);
});

// Set the initial slider state
var slider_state = "close";

function sliderAction()
{
	if (slider_state == "close")
	{
		sliderOpen();
		slider_state = "open"
		$(".slider_menu").html('<a href="#" onclick="return sliderAction();">[Close]</a>');
	}
	else if (slider_state == "open")
	{
		sliderClose();
		slider_state = "close";
		$(".slider_menu").html('<a href="#" onclick="return sliderAction();">...[More]</a>');
	}
	
	return false;
}

function sliderOpen()
{
	var open_height = $(".slider").attr("box_h") + "px";
	$(".slider").animate({"height": open_height}, {duration: "fast" });
}

function sliderClose()
{
	$(".slider").animate({"height": sliderHeight}, {duration: "fast" });
}
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑