user3235376
user3235376

Reputation: 87

DIV - toggle up

I need help with div' showing up.

I know, that code:

$( "#Button" ).click(function() {
  $('#leftDiv').toggle(2000);
});

will make my leftDiv dissappear (when I click Button), but what should I do to set my div default-hided(toggled down?) so that after I click Button, leftDiv should toggle up (appear)?

Upvotes: 2

Views: 122

Answers (3)

jbyrd
jbyrd

Reputation: 5585

var $leftDiv = $('#leftDiv');
var $button = $("#Button");

$leftDiv.hide();

$button.on('click', function() {
  $leftDiv.toggle(2000);
});

Upvotes: 0

j08691
j08691

Reputation: 207861

If you want the div hidden when the page loads, then .hide() it first:

$('#leftDiv').hide();
$( "#Button" ).click(function() {
  $('#leftDiv').toggle(2000);
});

Upvotes: 1

Night
Night

Reputation: 749

If you want the div to be hidden on load, you would do something like:

function load() {
document.getElementById("leftDiv").style.visibility="hidden";
}

<body onload="load"></body>

Would that not work?

Upvotes: 0

Related Questions