Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>$(document).ready() Equivalent without jQuery</title> <script> document.addEventListener("DOMContentLoaded", function(){ // Apply some style on paragraph document.getElementsByTagName("p")[0].style.background = "yellow"; console.log("DOM has been fully loaded and parsed."); }); </script> </head> <body> <h1>This is a heading</h1> <p>This is a simple paragraph of text.</p> </body> </html>