
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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>
- Related Questions & Answers
- What is $(document).ready() method in jQuery?
- How to check if a document is ready in JavaScript?
- Need Selenium to wait until the document is ready
- What is the difference between $(window).load() and $(document).ready() functions in jQuery?
- When to use $(document).ready() and when $(window).load() in jQuery?
- What is the Certainty Equivalent Method?
- Is their a negative lookbehind equivalent in JavaScript?
- What is Document Clustering Analysis?
- What is Python equivalent of the ! operator?
- What is the MySQL SELECT INTO Equivalent?
- What is the C++ equivalent of sprintf?
- What is the equivalent of EXCEPT in MySQL?
- What is the PHP stripos() equivalent in MySQL?
- Is their a JavaScript Equivalent to PHP explode()?
- What is the difference between HD ready and Full HD Televisions?
Advertisements