jQuery call a function after page loaded

This article uses jQuery to call a function after a page is loaded. Table of contents: 1. $(document).ready() 2. jQuery call a function after page loaded 3. References P.S Tested with jQuery 3.7.1 1. $(document).ready() In jQuery, the code inside the $(document).ready() method will run once when the Document Object Model (DOM) is ready, equivalent …

Read more

Check if element exists in jQuery

In jQuery, we can check if an element exists by using the jQuery selector to select it and .length() to check its length. If the length is greater than 0, it means the element exists. if ($("#elementId").length) { // The element exists } else { // The element does not exist } The above technique …

Read more

How to reload a page using jQuery

In jQuery, we can use the location.reload() to refresh or reload a page, which is part of the native JavaScript Window interface, not jQuery specifically. location.reload(); P.S Tested with jQuery 3.7.1 1. Reload a page using jQuery A complete example to show how to reload a page using jQuery. <!DOCTYPE html> <html lang="en"> <head> <meta …

Read more