javascript - Vertical Collapsible Panel - Displayed collapsed on Load - Stack Overflow

How would I be able to have a <div> already collapsed when the page loads? I have a JS Fidle with

How would I be able to have a <div> already collapsed when the page loads?

I have a JS Fidle with what I've got so far.


HTML

<button id="aa">Toggle it up</button>

<div id="test">TEST</div>

CSS

div { 
    background:#0F0; 
    margin:3px; 
    width:600px; 
    height:600px; 
    float:right;
}
div.test { 
    background:#345; 
    width:5px;
}
#aa {width: 100px; 
    height: 600px;
    position: absolute;
    top: 3px;
    right: 0px;
    z-index: 10 
    float: right;
}

JAVASCRIPT

$("#aa").click(function () {
    $("div").animate({width: 'toggle'});;
});

How would I be able to have a <div> already collapsed when the page loads?

I have a JS Fidle with what I've got so far.


HTML

<button id="aa">Toggle it up</button>

<div id="test">TEST</div>

CSS

div { 
    background:#0F0; 
    margin:3px; 
    width:600px; 
    height:600px; 
    float:right;
}
div.test { 
    background:#345; 
    width:5px;
}
#aa {width: 100px; 
    height: 600px;
    position: absolute;
    top: 3px;
    right: 0px;
    z-index: 10 
    float: right;
}

JAVASCRIPT

$("#aa").click(function () {
    $("div").animate({width: 'toggle'});;
});
Share edited Feb 11, 2014 at 13:12 Potherca 14.7k5 gold badges84 silver badges106 bronze badges asked Feb 11, 2014 at 12:51 user3297149user3297149 131 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

CSS

Hide the div using css

#test{
  display:none;
}

Fiddle Demo


jQuery

$('#test').hide();

JavaScript

document.getElementById('test').style.display = 'none';

CSS

#test{
  display:none;
}

DEMO

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744951586a4602953.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信