js dom ready function

JavaScript
$(document).ready(function(){
  $("button").click(function(){
    $("p").slideToggle();
  });
});<!doctype html>
<html>
<head>
</head>
<body>
Your HTML here

<script>
// self executing function here
(function() {
   // your page initialization code here
   // the DOM will be available here

})();
</script>
</body>
</html>

Source

Also in JavaScript: