views:

405

answers:

3

Stupid question time - how do you update the title attribute of a control? Obviously this does not work:

$("#valPageIndex").attr('title') = pageIndex;

TIA

+5  A: 
$("#valPageIndex").attr({'title': pageIndex});
Fermin
Dang... 8 seconds :P
Seb
+7  A: 
$("#valPageIndex").attr('title', pageIndex);

Basically, $("#valPageIndex").attr('title') is just for getting its value, while $("#valPageIndex").attr('title', value) is for setting it.

Here's the official doc: http://docs.jquery.com/Attributes/attr.

Seb
Link to the documentation and you got my vote ;)
Paolo Bergantino
lol just for you! ;)
Seb
+2  A: 
$("#valPageIndex").attr('title', pageIndex);

http://docs.jquery.com/Attributes/attr#keyvalue

A common jQuery convention is to have .foo() or .foo('selector') act as a getter and .foo(value) or .foo('selector', value) act as a setter.

Ben Blank