Simple JQuery question - how do you add value to title attribute?

Silly question - how do you update the title attribute of the control? Obviously this doesn't work:

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

      

0


a source to share


3 answers


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

      

Basically, it is $("#valPageIndex").attr('title')

intended to get its value, and $("#valPageIndex").attr('title', value)

- to set it.



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

+8


a source


$("#valPageIndex").attr({'title': pageIndex});

      



+5


a source


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

      

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

A general convention for jQuery is to .foo()

either .foo('selector')

act as a receiver and .foo(value)

or .foo('selector', value)

act as a setter.

+2


a source







All Articles