2022.2

Table Of Contents
results.closest("tr");
Therowscouldbecoloredredwithinthesamestatement:
results.closest("tr").css('background-color','red');
css()
GetsthevalueofastylepropertyofoneHTMLelement,orsetsoneormoreCSSpropertiesofoneor
moreHTMLelements.
css(styleName) : String
ReturnsthevalueofthespecifiedCSSpropertyofanHTMLelement,whichcanbe:
l
Thefirstelementinasetofelementsthatmatchtheselectorofascript(see"results"on
page844).
l
Oneelementthatmatchestheselectorofascriptthatrunsfor"Eachmatchedelement"(see
"this"onpage781and"Settingthescopeofascript"onpage373).
l
Thefirstelementinasetofelementsreturnedbyaqueryinthetemplate(see"query()"on
page742).
propertyName
String;thenameoftheCSSproperty.
Examples
Thisscriptstoresthetextcoloroftheresults(theHTMLelementsthatmatchtheselectorofthe
script)inavariable.
var textcolor = results.css("color");
ThefollowingscriptlooksupanelementwiththeID#calloutboxandstoresitsbackgroundcolorina
variable.
var backgroundcolor = query("#calloutbox").css("background-color");
css(styleName, value)
FunctiontosetaCSSpropertyofoneHTMLelementorofeachelementinaresultset.
Page 761