In this tutorial, learn how to get current page URL on click in jQuery. The short answer is: use the code snippet $(location).attr('href') to get current page full URL. The current page URL is the URL you can find in the address bar.

The current URL in the address bar is the absolute path given in the address bar. When you see the address bar, you can find the URL which is the location you can get using jQuery. You may also like to read how to get selected checkboxes id on click using jQuery.

How to Get Current Page URL on Click Using jQuery

To get current Page URL, you have to use the code snippet $(location).attr('href')

Output



Click the above button to find URL of the current page. The current page URL is the URL you can find in the address bar. You will get an alert message on click of the button. The alert message containing the URL or location of the current page.

You may also like to read.

Hope, you like this tutorial of how to get URL of current page in jQuery. If you have any query regarding the tutorial, please comment below.

Also tell me, which method are you using to get current page URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.