JavaScript How to hide div on load of webpage

I have a basic script which shows/hides a div. I'm using this for a drop-down menu.

https://www.w3schools.com/howto/howto_js_toggle_hide_show.asp

I'm looking for the div element to be hidden when the page loads instead of it showing and having to click it to toggle it.

Any help is appreciated!

Answer:1

Use display: none in div like below

<div id="myDIV" style="display:none">
  This is my DIV element.
</div>

or you can create a class and assign to the div.

<style>
.hide{
   display:none;
}
</style>


<div id="myDIV" class="hide">
  This is my DIV element.
</div>
Answer:2

Instead of CSS, you may also use JavaScript to manipulate the display of a web page by taking advantage of events, such as onload.

window.onload = function(){
  document.getElementById("myDIV").style.display='none';
};
<div>
  This is the first DIV element.
</div>

<div id="myDIV">
  This is the 2nd DIV element.
</div>

<div>
  This is the last DIV element.
</div>
Answer:3

I'm using this library here: ng-sortable And I'm using it on a table. The thing is, when I physically drag a table row, the row shrinks and doesn't keep the original look of the table. I narrowed ...

I'm using this library here: ng-sortable And I'm using it on a table. The thing is, when I physically drag a table row, the row shrinks and doesn't keep the original look of the table. I narrowed ...

I have the following array var x = [{"id":"757382348857","title":"title","handle":"linkhere","productimage":"url","ippid":true,"location_x":26,"location_y":18}] And i am trying to add the following ...

I have the following array var x = [{"id":"757382348857","title":"title","handle":"linkhere","productimage":"url","ippid":true,"location_x":26,"location_y":18}] And i am trying to add the following ...

  1. concatenate arrays with different dimensions python
  2. concatenate arrays with different dimensions matlab
  3. concatenate arrays with numpy
  4. concatenate arrays with python
  5. concatenate arrays with
  6. concat arrays with spread operator
  7. concat arrays with reduce
  8. concatenate arrays in matlab
  9. concatenate arrays of different sizes matlab
  10. concatenate arrays of different sizes python
  11. concatenate arrays in java
  12. concatenate arrays in javascript
  13. concatenate arrays in c
  14. concatenate arrays in r
  15. concatenate arrays in list python
  16. concatenate arrays in excel
  17. concatenate arrays in loop matlab
  18. concatenate arrays of different sizes numpy
  19. concatenate arrays in php
  20. concatenate arrays in a list

An API I'm working with is returning poorly structured data like this: { "scsi0": "vm-101-disk-1.qcow2,size=32G", "scsi1": "vm-101-disk-2.qcow2,size=32G", "scsi2": "vm-101-disk-3.qcow2,...

An API I'm working with is returning poorly structured data like this: { "scsi0": "vm-101-disk-1.qcow2,size=32G", "scsi1": "vm-101-disk-2.qcow2,size=32G", "scsi2": "vm-101-disk-3.qcow2,...

My submit button is finally working. However, it is not counting all of the votes in the results. How do I get my submit button to sort all of the votes? HTML: <!DOCTYPE html> <html&...

My submit button is finally working. However, it is not counting all of the votes in the results. How do I get my submit button to sort all of the votes? HTML: <!DOCTYPE html> <html&...

  1. sort keys array php
  2. sort keys array javascript
  3. sort array keys
  4. sort array keys alphabetically php
  5. sort array keys descending php
  6. sort array keys js
  7. sort array keys descending order php
  8. sort array keys by value