2022.2

Table Of Contents
Examples
Thisscript-withtheselectorimg-storesthesourceofthefirstimageinavariable.
var src = results.attr("src");
ThefollowingscriptlooksupanimagewiththeID#image1andstoresitsbackgroundcolorinavari-
able.
var imgURL = query("#image1").attr("src");
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).
Page 756