Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to add a title in anchor tag using jQuery?
To add a title in anchor tag in jQuery, use the prop() method. The prop() method is used to set properties and values of the selected elements.
You can try to run the following code to learn how to add a title in anchor tag using jQuery −
Example
<html>
<head>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#button1").click(function(){
$('.myClass').prop('title', 'This is your new title');
var myTitle = $('.myClass').prop('title');
alert(myTitle);
});
});
</script>
</head>
<body>
<div id='div1' class="myclass">
<a class="myClass" href='#'><img src='http://tutorialspoint.com/green/images/logo.png' /></a><br>
<button id="button1">Get Title</button>
</div>
</body>
</html> Advertisements
