Why document.ready is used in jQuery

后端 未结 4 537
忘掉有多难
忘掉有多难 2020-12-20 04:37

What is the exact use of $(document).ready() in jQuery and can we have two $(document).ready() in a webpage?

4条回答
  •  半阙折子戏
    2020-12-20 04:43

    use of Document.ready in Jquery

    At times you need scripts to run on page load. But there might be some elements that are not completely loaded while executing your script. To make it safe to run, we use $(document).ready(function { /* to do here */}) or short hand $(function { /* to do here */});

    can we have two document.ready in a webpage

    Yes, you can have multiple.

提交回复
热议问题