views:

6989

answers:

4

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
Thanks a ton! Very helpful
Brian
+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
+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
+1  A: 
$('title').html('someHTML'); 

Why this method? Try localization.

hektor
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