How to run a code on document ready event in jQuery ? Last Updated : 29 May, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will see how to run a code when a page loads using jQuery. To run a code at page load time, we will use the ready() method. This method helps to load the whole page and then execute the rest code. This method specifies the function to execute when the DOM is fully loaded. Syntax: $(document).ready(function) Parameters: This method accepts a single parameter function which is mandatory. It is used to specify the function to run after the document is loaded. Return Value: This method returns the document after performing the ready() method. Example: In this example, we will use the ready() method. HTML <!DOCTYpe html> <html> <head> <title> How to run a code on document ready event in jQuery? </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <!-- jQuery code to show the working of this method --> <script> $(document).ready(function () { $("body").css("text-align", "center"); $("h1").css("color", "green"); $("p").css("font-size", "14px"); $("p").css("font-weight", "bold"); }); </script> </head> <body> <h1>GeeksforGeeks</h1> <h3> How to run a code on document ready event in jQuery? </h3> <p>GeeksforGeeks: A computer science portal</p> </body> </html> Output: Comment More infoAdvertise with us Next Article How to run a code on document ready event in jQuery ? V vkash8574 Follow Improve Article Tags : Web Technologies JQuery HTML-Tags jQuery-Methods HTML-Questions +1 More Similar Reads How to run a code on double-click event in jQuery ? In this article, we will see how to run a code after double clicked the element using jQuery. To run the code on double clicked we use dblclick() method. This method is used to trigger the double-click event to occur. This method occurs when the selected element will be double clicked. Syntax: $(sel 1 min read How to run a code on hover event in jQuery ? In this article, we will see how to change the style of elements on hover event using jQuery. To change the style of hover event, hover() method is used. The hover() method is used to specify two functions to start when the mouse pointer moves over the selected element. Syntax: $(selector).hover(Fun 1 min read How to run a code on click event in jQuery ? In this article, we will see how to run the code after clicking on an event. To run the code after clicking an event, we use the click() method. The click() method is used to run the code when a click event occurs. The click() method to attach a click event handler to selected elements. Inside the h 1 min read How to run a code on scroll event in jQuery? In this article, we will discuss how to run the code when users scroll the content using jQuery. To run the code on scrolling the content, the scroll() method is used. The scroll() method is used to run the code when the user scrolls in the specified element.Syntax:$(selector).scroll(function)Parame 2 min read How to run a code on mouseenter event in jQuery ? In this article, we will see how to run the code when the mouse enters into the specific area using jQuery. To run the code on a mouse enter a specific area, mouseenter() method is used. The mouseenter() method works when the mouse pointer moves over the selected element. Syntax: $(selector).mouseen 1 min read Like