Quirky jQuery - Setting the 'value' attribute in HTML


This one stumped the guys over at the jQuery IRC channel:

When you use the jquery to set an element's value attribute, you can do the following:

$(this).attr('value', 'newvalue');

or this:


For most attributes, this will change the actual html. To test it out, you can use Firebug and watch the value change, or print out the new output by doing something like:

Syndicate content
Implied By Design Logo