How to get title of current HTML page using jQuery ? Last Updated : 02 Mar, 2020 Comments Improve Suggest changes Like Article Like Report Suppose you have given an HTML page and the task is to get the title of an HTML page with the help of only jQuery. There are two approaches that are discussed below: Approach 1: The $('title') jQuery selector is used to select the title element of the document and we can use text() method on the selector to get the title of the document. Example: html <!DOCTYPE HTML> <html> <head> <title> Get title of current HTML page </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <style> body { text-align:center; } #gfg{ color: green; font-size: 24px; font-weight: bold; } </style> </head> <body> <h1 style="color:green;"> GeeksforGeeks </h1> <b> Click on button to get HTML document's title </b> <br><br> <button onClick="GFG_Fun()"> click here</button> <p id="gfg"> </p> <script> var down = document.getElementById('gfg'); // Main function function GFG_Fun() { down.innerHTML = $('title').text(); } </script> </body> </html> Output: Approach 2: The $(document) jQuery selector is used to select the HTML document and we can use attr() method on the selector to get the title of the document by passing 'title' as argument. Example: html <!DOCTYPE HTML> <html> <head> <title> Get title of current HTML page </title> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script> <style> body { text-align:center; } #gfg{ color: green; font-size: 24px; font-weight: bold; } </style> </head> <body> <h1 style="color:green;"> GeeksforGeeks </h1> <b> Click on button to get HTML document's title </b> <br><br> <button onClick="GFG_Fun()"> click here</button> <p id="gfg"> </p> <script> var down = document.getElementById('gfg'); // Main function function GFG_Fun() { down.innerHTML = $(document).attr('title'); } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to get title of current HTML page using jQuery ? P PranchalKatiyar Follow Improve Article Tags : Web Technologies JQuery jQuery-Questions Similar Reads How to get the outer html of an element using jQuery ? Sometimes, there is a need to get the entire HTML element by its id and not merely its contents, for doing so, we shall use the HTML DOM outerHTML Property to get the outer HTML of HTML element. Syntax: document.getElementById("your-element-id").outerHTML) You can use a variable and initialize it to 2 min read How to get the title of an HTML page ? In this article, we will see how to get the title of HTML page using JavaScript. There is a number of ways to do this but here we discuss a few of the most preferred methods. Example 1: This example gets the title of the document by using document.title property. html <!DOCTYPE html> <html 1 min read Get the current URL using jQuery The current URL in jQuery can be obtained by using the 'href' property of the Location object which contains information about the current URL. The href property returns a string with the full URL of the current page. We can access the value of the href property using two different methods of jQuery 2 min read How to jump to top of browser page using jQuery? When the website contains lots of data on a single page and while seeing down the website, if the user wants to see the main content i.e, top of the browser page without scrolling, this can be achieved by using jQuery. Example: Jump to the top of the browser page html <html> <head> <s 1 min read How to Print a Page using jQuery? Printing a webpage directly from the browser can be a useful feature for users who want a physical copy of the content. With jQuery, a popular JavaScript library that simplifies HTML document manipulation and event handling, you can easily implement a print function on your webpage. This guide will 2 min read Like