
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Add 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