jQuery Get Current Page Title

By Sam Deering

jQuery code snippet to get the current web page full title and store it in a variable for use with other scripts. This is the title you see on your browser header.

Current page title: mytitle.

Another way suggested by Andy.

var current_href = $(location).attr('href');
var current_title = $(document).attr('title');
  • Pingback: jQuery Get Current Page Title | Web Design Northamptonshire()

  • Pingback: jQuery Get Current Page Title « Big Engine Media()

  • Andy Newby

    Are you sure??? For me it doesn’t work. Managed to work out this does work though:

    var current_href = $(location).attr(‘href’);
    var current_title = $(document).attr(‘title’);

    Just thought I would share in case anyone else has this problem ;)

    • jQuery4u

      Thanks Andy, post updated.

  • Carol Skelly

    Thanks Andy, that worked for me too.

Get the latest in JavaScript, once a week, for free.