How do I find the title text of a link in jquery.
+2
A:
$("a").click(function(e){
e.preventDefault();
var title = $(this).attr("title");
});
Jonathan Sampson
2010-01-08 06:44:10
+2
A:
You can use attr
to find title
attribute.
var title = jQuery("a").attr("title"); //replace "a" with your own selector
Chandra Patni
2010-01-08 06:44:22
+1
A:
If you're trying to get the text of the title attribute of the link, you can use this, assuming that myLink
is a jQuery object of your link:
myLink.attr("title")
However, if you mean the actual text of the link, then you can use this:
myLink.text()
You can read the jQuery documentation for the attr
method here and the documentation for the text
method here.
icktoofay
2010-01-08 06:45:11