How to get title of current HTML page using jQuery ? Last Updated : 12 Jul, 2025 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 jump to top of browser 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 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 How to add a title in anchor tag using jQuery ? In this article, we will see how to add a title in the anchor tag using jQuery. The title property is used to specify extra information about the element. When the mouse moves over the element then it shows the information. The prop() method is used to add properties and values to the element using 2 min read How to get the size of screen, current web page and browser window using jQuery? jQuery can be used to get the dimensions of the current page. The dimensions include the screen, viewport and document height, and width. Getting the window dimensions: Window size is the size of the browser window. This is the size that changes when the browser is resized. The windows height and wi 2 min read Like