I have an form input element and I want to change it's title attribute. This has got to be easy as pie but for some reason I cannot find how to do this. How is this done and where and how should I be searching on how to do this?
+13
A:
$('yourelement').attr("title", "your new title");
Check out the API documentation for jQuery. This is where I found it: http://docs.jquery.com/Attributes
Cory Larson
2009-06-12 17:33:27
Thanks a ton! Very helpful
Brian
2009-06-12 17:37:59
+3
A:
I beleive
$("#myElement").attr("title", "new title value")
should do the trick...
I think you can find all the core functions in the jquery docs, although I hate the formatting: http://docs.jquery.com/Main_Page
womp
2009-06-12 17:34:17
+1
A:
Another option, if you prefer, would be to get the DOM element from the jQuery object and use standard DOM accessors on it:
$("#myElement")[0].title = "new title value";
The "jQuery way", as mentioned by others, is to use the attr() method. See the API documentation for attr() here.
Greg Campbell
2009-06-12 17:44:04
I don't understand this reply -- is it quoting another reply that's been deleted? The question was about changing an input element's title attribute, not the HTML of a title element.
Sam Dutton
2010-08-09 07:46:37