1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

show/hide different div ID's

Discussion in 'Web Design & Development' started by mwdesign, Jul 23, 2012.

Thread Status:
Not open for further replies.
  1. mwdesign

    mwdesign Thread Starter

    Aug 20, 2010
    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:

    // Set the initial height
    var sliderHeight = "45px";
    	// Show the slider content
    	$('.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")
    		slider_state = "open"
    		$(".slider_menu").html('<a href="#" onclick="return sliderAction();">[Close]</a>');
    	else if (slider_state == "open")
    		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
As Seen On...

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.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1062255