2022.2

Table Of Contents
attr(attributeName, value)
SetsthevalueofthespecifiedattributeofoneHTMLelementorofeachelementinaresultset.
attributeName
String;thenameoftheattribute.
value
String;valuefortheattribute.
Examples
ThisscriptlooksupanimageinanelementwiththeID#calloutboxandsetsitsalternativetexttoa
valuefromadatafield.
var altText = record.fields.FavHobby;
query("#callout img").attr('alt', altText);
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844).
l
Oneelementthatmatchestheselectorofascriptthatrunsfor"Eachmatchedelement"(see
"this"onpage781and"Settingthescopeofascript"onpage373).
l
Theelementsreturnedbyaqueryinthetemplate(see"query()"onpage742).
Seealso:"after()"onpage786.
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.
Page 791