js document onready code example

Example 1: js document ready

$( document ).ready(function() {
    console.log( "ready!" );
});

Example 2: document ready javascript

$(document).ready(function(){
  $("button").click(function(){
    $("p").slideToggle();
  });
});

Example 3: js dom ready function

<!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>