![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is $(document).ready() equivalent in JavaScript?
In jQuery, if you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.
$(document).ready(function() { alert(“Document loaded successful!"); });
Example
In JavaScript, to achieve the same result like $(document).ready, try the following code −
<html> <body> <script> var loader = setInterval(function () { if(document.readyState !== "complete") return; clearInterval(loader); alert(“Document loaded successful!"); // document.write("Document loaded successful!"); }, 300); </script> </body> </html>
Advertisements