How to get Page Title and URL using jQuery

Yesterday for one of my requirement, I need to get the title and URL of the page. This can be easily done with jQuery. In this post, I will show you a jQuery code snippets which will get the URL and Title of the page using jQuery.

$(document).ready(function () {
   var vhref = $(location).attr('href');
   var vTitle = $(this).attr('title');
   $('#spnTitle').html('' + vTitle + '');
   $('#spnURL').html('' + vhref + '');
See result below.

Feel free to contact me for any help related to jQuery, I will gladly help you.

Nothing shocks me, I'm a Software Engineer. And I am not young enough to know everything. I live in World Wide Web and from there take care of this website. This website communicates about my work, learning and experience. I believe life is short, and it is for loving, sharing, learning and connecting. So lets connect..