简单的JQuery问题 - 如何为title属性添加值?

Kei*_*ows 0 jquery attributes

愚蠢的提问时间 - 如何更新控件的title属性?显然这不起作用:

$("#valPageIndex").attr('title') = pageIndex;
Run Code Online (Sandbox Code Playgroud)

Seb*_*Seb 8

$("#valPageIndex").attr('title', pageIndex);
Run Code Online (Sandbox Code Playgroud)

基本上,$("#valPageIndex").attr('title')只是为了获得它的价值,而$("#valPageIndex").attr('title', value)用于设置它.

这是官方文档:http://docs.jquery.com/Attributes/attr.

  • 链接到文档,你得到了我的投票;) (3认同)

Fer*_*min 5

$("#valPageIndex").attr({'title': pageIndex});
Run Code Online (Sandbox Code Playgroud)