2022.2

Table Of Contents
Thefollowingscriptsetsthebackgroundcolorofaspecifictablecellinanemailtoredifthevalueofthe
fieldTOTALhasanegativevalueinthecurrentrecord.
if(record.fields.TOTAL<0) {
query("#total").attr("bgcolor","red");
}
before()
InsertscontentbeforeoneormoreHTMLelements,whichcanbe:
l
Theelementsthatmatchtheselectorofascript(see"results"onpage1301).
l
Oneelementthatmatchestheselectorofascriptthatrunsfor"Eachmatchedelement"(see
"this"onpage1237and"Settingthescopeofascript"onpage813).
l
Theelementsreturnedbyaqueryinthetemplate(see"query()"onpage1197).
Seealso:"after()"onpage1242.
before(content)
Before(content)insertscontentbeforeoneormoreHTMLelementsandcreatesanewresultset.
content
String,HTMLstringorresultsettoinsertaftertheelements.Incaseaplaintextstringisprovided,itis
automaticallywrappedina<span>elementtoavoidorphantextnodestoappearinthe<body>ele-
ment.
Examples
ThisscriptlooksforanelementwiththeIDsalesrepandinsertsaparagraphbeforethatelement.
results.before("<p>Lorem Ipsum</p>");
Selector Matched element Matched element after script execution
#salesrep <pid="salesrep">PeterParker</p> <p>Loremipsum</p>
<pid="salesrep">PeterParker</p>
Thisscriptdoesthesame,butitusesthequery()functiontolookuptheelement.
query("#salesrep").before("<p>Lorem ipsum</p>");
Page 1248