Loading…

How do you get the attribute of an HTML tag in jQuery?

Developers can use this.title function inside the function to get the attribute of an HTML tag in jQuery. Use the following script:

Example

                                        

$('a').click(function() {
    var myTitle = $(this).attr ( "title" ); // from jQuery object
    //var myTitle = this.title; //javascript object
    alert(myTitle);
});

 

Suggest An Answer

No suggestions avaliable!

Latest post from Jquery interview questions

Ask Question