문제

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'});;
});
도움이 되었습니까?

해결책 2

CSS

#test{
  display:none;
}

DEMO

다른 팁

CSS

Hide the div using css

#test{
  display:none;
}

Fiddle Demo


jQuery

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

JavaScript

document.getElementById('test').style.display = 'none';
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top