2022.2

Table Of Contents
Tip: Doyoufindyourselfcopy-pastingthesamefunctionintoeverynewscript?Youcanavoid
thisbydefiningyourfunctioninaControlScript.ControlScriptsareexecutedfirst,sothefunction
willthenbeavailableinallStandardScriptsandPostPaginationScripts.
Note: AnyJavaScriptfilesincludedinasectionrunafterthescriptsintheScriptspane.
Selectors in OL Connect
SelectorsarepatternsusedtoselectoneormoreHTMLelements.Theywereoriginallydevelopedto
beabletodefinethelayoutofwebpageswithouttouchingtheircontent,throughCascadingStyle
Sheets(CSS).InOLConnect,sinceeachsectioninatemplateisinfactanHTMLfile(see"Editing
HTML"onpage171),theverysameselectorscanbeusedinstylesheets(see"Stylingtemplateswith
CSSfiles"onpage261)andStandardScripts(see"Personalizingcontent"onpage297and"Writing
yourownscripts"onpage368).Usingselectorsforscriptingcanincreasethespeedwithwhichatem-
plateanddataaremerged;see"UseanIDorclassasselector"onpage381.
StandardCSSselectors
Selectorsaremadeupofoneormoreofthefollowingcomponents:
l
AnHTML element.TypetheHTMLtagwithouttheanglebrackets(e.g.p)toselectallelements
ofthattype(pselectsallparagraphs).
l
Aclass.Typetheclassname,precededbyadot,e.g.:.green,toselectHTMLelementswith
thatclass.
l
AnID.TypetheID,precededby#,e.g.:#intro,toselectanHTMLelementwiththatID.
Note: InanHTMLfile,eachIDshouldbeunique.ThismeansthataparticularIDcanbe
usedonlyonceineachsection.
l
AnattributeofanHTMLelement.Typetheattributeand,optionally,itsvalue,betweensquare
brackets,e.g.:[target],toselectHTMLelementswithamatchingattribute.
l
Apseudo-class.Forexample,tr:nth-child(even)selectsalleventablerows.
Thesecomponentscanbecombinedindifferentways.Forexample,p divselectsallparagraphs
inside<div>elements,whilep, divselectsallparagraphsandall<div>elements.
Acompletelistofselectorsandwaystocombinethem,andatoolthatdemonstratestheirusecanbe
foundatW3Schools:http://www.w3schools.com/cssref/css_selectors.asp.
AvideoaboutCSSandScriptSelectors,canbefoundhere:ConnectwithEvie6-CSSandScript
Selectors.
Page 385