Web Development Ninjas Question:

Download Job Interview Questions and Answers PDF

Explain me what is $(document).ready() function? Why should you use it?

Ninjas Web Developer Interview Question
Ninjas Web Developer Interview Question

Answer:

This is one of the most important and frequently asked questions. The ready() function is used to execute code when document is ready for manipulation. jQuery allows you to execute code, when DOM is fully loaded i.e. HTML has been parsed and the DOM tree has been constructed. The main benefit of $(document).ready() function is that, it works in all browser, jQuery handles cross browser difficulties for you. For curious reader see answer link for more detailed discussion.

Download Ninjas Web Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Explain me how do you set an attribute using jQuery?Tell me what is the difference between SVG and <Canvas>?