Get current URL with jQuery

Sometimes you need to retrive the current URL of the page. It is very easy in jQuery style:

var currentURL = $(location).attr("href");

 

It can be very useful for social plugins. You can learn more about location object on w3schools.

Leave a Reply