g(..).writeAttribute(attr, val)

Sets the attribute specified by attr of all elements in the Gimme Object to the value specified by val.

Returns: Itself (the same Gimme Object is returned so additional methods can be chained together seamlessly).
Params:
  • attr, required: The name of the attribute to be set (ex: 'href' or 'cols')
  • val, required: The value to which the specified attribute is to be set.

Examples:
// sets the href attribute of all <a> elements on the page that have the class "map" to "http://maps.live.com"
g('a.map').writeAttribute('href', 'http://maps.live.com');

// sets the made-up "foo" attribute of every element on the page to "bar" (creates the attribute as it most likely will not already exist)
var bar = g('*').writeAttribute('bar');

// sets the rows attribute of the <textarea> whose id is "txtArea" to 50
g('#txtArea').writeAttribute('rows', '50');

Last edited Nov 13, 2007 at 7:24 PM by sstchur, version 1

Comments

No comments yet.