javascript - jQuery Show/Hide divs one at a time -


i have modified code in post jquery div content partial hide, show all show/hide list of div's on page.

i still learning jquery , trying figure out how can modify code when open 1 div, close other's open.

thanks lot help. here code block:

    function setscroll(){     var slideheight = 80;     $(".container").each(function() {     var $this = $(this);     var $wrap = $this.children(".wrap");     var defheight = $wrap.height();     if (defheight >= slideheight) {         var $readmore = $this.find(".heading");         $wrap.css("height", slideheight + "px");         $readmore.append("<div id='clickbutton' class='expand-div'>click more info</div>");          $readmore.children("#clickbutton").bind("click", function(event) {                 var curheight = $wrap.height();                   if (curheight == slideheight) {                 $wrap.animate({                     height: defheight                 }, "normal");                                 $(this).removeclass("expand-div").addclass("collapse-div");                 $(this).text("close");                 $wrap.children(".gradient").fadeout();                       } else {                 $wrap.animate({                     height: slideheight                 }, "normal");                 $(this).removeclass("collapse-div").addclass("expand-div");                 $(this).text("click more info");                 $wrap.children(".gradient").fadein();             }             return false;         });     } }); } 

simple example (jsfiddle) demonstrates closing , opening one.

var divs = $('div.highlander').hide(); var = divs.length; $('#cycler').click(function () {     += 1;     if (which >= divs.length) {         = 0;     }     divs.hide();     divs.eq(which).show(); }); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -