JavaScript element.title Property

You are Here:

JavaScript element.title Property

The element.title property gets or sets the value of the title attribute of an element.

Get the title

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <p><abbr title="World Wrestling Entertainment">WWE</abbr> is awesome.</p> <p>Click on the button to display the title of WWE.</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <script> var x = document.getElementById("point"); var elem = document.getElementsByTagName("abbr")[0]; function myFunction(){ x.innerHTML = elem.title } </script> </body> </html>

Syntax

element.title

Return Values

ValueExplanation
StringReturns the title of the specified element.

Set the title

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <p><abbr>WWE</abbr> is awesome.</p> <p>Click on the button to add title to the abbr for WWE.</p> <button onclick="myFunction()">Click Me</button> <script> var elem = document.getElementsByTagName("abbr")[0]; function myFunction(){ elem.title = "World Wrestling Entertainment"; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author