Open In App

How to get title of current HTML page using jQuery ?

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.

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.


Article Tags :