2022.2

Table Of Contents
Theclosest()commandisbasedontheclosest()commandfoundinthejQuerylibrary:
https://api.jquery.com/closest/.
Togetanelement'ssiblingelement,youcanuse"prev()"onpage1264or"next()"onpage1258.
closest(selector)
ForoneHTMLelementorforeachelementinaset,thisfunctiongetsthefirstelementthatmatchesthe
selectorbytestingtheelementitselfandtraversingupthroughitsancestorsintheDOMtree.
selector
AStringcontaininganHTMLtag(withouttheanglebrackets,<>).
Examples
Thefollowingscriptlooksupalltablerowsinthetemplatethatcontainan<input>element.
query("input").closest("tr");
Thiscodegetstheclosest'parent'rowforeachelementthatmatchestheselectorofthescript(col-
lectedintheresultsobject):
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
page1301).
l
Oneelementthatmatchestheselectorofascriptthatrunsfor"Eachmatchedelement"(see
"this"onpage1237and"Settingthescopeofascript"onpage813).
l
Thefirstelementinasetofelementsreturnedbyaqueryinthetemplate(see"query()"on
page1197).
Page 1252