g(..).setStyle(styleName, val)

Sets the .style[styleName] property of each element in the Gimme Object's internal array.

Returns: Itself (the same Gimme Object is returned so additional methods can be chained together seamlessly).
  • styleName, required: a string specifying the style property to be set (ex: 'backgroundColor').
  • val, required: a string value to be assigned to .style[styleName] property.

// set the opacity of all <p> elements with the class "funny" to .5 (50%)
g('p.funny').setStyle('opacity', .5);

// sets the display of all <span> elements to block
g('span').setStyle('display', 'block');

// sets the backgroundColor of all <div>elements with the class "lovely" to pink while also setting the border to 5px solid red
g('div.lovely').setStyle('backgroundColor', 'pink').setStyle('border', '5px solid red');

Last edited Jun 8, 2007 at 6:48 AM by sstchur, version 1


No comments yet.