WordPress Code Snippets

A fresh mix of code snippets and tutorials

jQuery Reload Current Page on Click


jQuery makes it easy to do all kinds of cool stuff. For example, here is a code snippet to reload the current page with a click.

Let’s say you have an HTML link such as:

<a class="reset" href="#">Refresh Page</a>

Adding the following jQuery script will reload the current page when clicked:

Keep in mind that if you know the URL of the page that will contain the link, there is no need for JavaScript, as you can simply write:

<a class="reset" href="/current-page/">Refresh Page</a>

..where /current-page/ is the relative URI of the current page. Thus, the jQuery reload technique is useful in scenarios where the page URL is not known at page load. For example, when redirecting to a user-submitted post.

Show Support

Like our new Facebook Page to show support!