2022.2

Table Of Contents
Whatiftherearenosiblings?
Ifyoucallprev()ornext()onacollectionofelements(either"results"onpage1301ortheresult
setof"query()"onpage1197),thefunctionwillreturnacollectionofsiblings.Ifnoneoftheelements
hasapreviousornextsibling,thecollectionwillbeempty.Actionsperformedonanemptycollection
willsimplyhavenoeffect.
Ifyoucallprev()ornext()onasingleelement(thisinan'Eachmatchedelement'script),andthe
elementhasnopreviousornextsibling,thefunctionreturnsnull.Performinganoperationonanull
valuewillresultinanerror,whichmeansthattherestofthescriptwon'tbeexecuted.Inthiscase,itis
usefultocheckthereturnvalue,unlessit'scertainthatitwillneverbenull.
Example
AssumethattherearethreeconsecutiveparagraphsinaBoxandthatthesecondofthoseparagraphs
hasanIDthatmatchestheselectorofthisscript.Theparagraphisstoredintheresultsobject(see"res-
ults"onpage1301).Thefollowingscriptchangesthefont-weightofthenextparagraph-thethirdpara-
graphintheBox-tobold.
results.next().css("font-weight", "bold");
Iftheelementsinresultsdon'thavesiblings,thislineofcodewillhavenoeffect.Italsowon'tresultin
anerror.
Inan'Eachmatchedelement'scriptyouwouldfirstneedtocheckthereturnvalueofthis.next():
var nextSibling = this.next();
if nextSibling != null { nextSibling.css("font-weight", "bold"); }
overflows()
Theoverflows()methodreturnsabooleanvalueindicatingwhetheranHTMLelementoverflowsits
boxboundaries.
Thisfunctioncouldforinstancebeusedinadesignwherecontentneedstoflowseparatelyfromthe
maintextflow,orwhereanew,full-page,multi-columnboxshouldbeinsertedwhenthecurrentone
overflows.
NotethatwhencalledinaStandardscript,thismethodrunsbeforethepaginationofPrintoutput.After
pagination-intheoutput,andinPreviewmode-theelement'soverflowmayhavechanged,especially
whentheelementiscombinedwithfloatingelements(i.e.elementsthathavetheCSSstylefloat)and
locatednearapage-break.
Topreventthisfromhappening,itmayhelptosettheelement'sCSSstyletooverflow:hidden.
Theoverflows()methodcanalsobeusedinaPostPaginationscript.
Page 1259