Modify Attribute Action

The Modify Attribute action adds, removes, or changes the value of an attribute on one or more specific elements.

Monetate uses an attribute to define the characteristics of an element and places them inside the element's opening tag. Some examples of attributes include class, id, placeholder, src, href, and many others.

This action allows you to add or alter an element's attribute without breaking any existing JavaScript bindings on that element. For example, it allows you to edit the href location of a link without inserting a new copy of the link. This modification method keeps any data tracking already bound to that link with JavaScript intact.

Required Components

Relative Element Selector

Enter the element selector into Relative Element Selector. This selector determines which element's attribute the action adds, removes, or edits. For additional information on element selectors, refer to Element Selectors.

Attribute

Specify the attribute that you want the action to add or modify (for example, href or src). If it exists, then Monetate alters its value. If it doesn't exist, then Monetate adds it to the element with its optional value.

Optional Components

Replacement Value

Input the value(s) that you want the action to insert if you are adding or modifying the current value of an attribute. If you're removing the attribute, then you can leave this field blank.

CSS Style

Anything you add to the CSS editor is appended to a stylesheet in the <head> portion of your site in a <style> block. These styles are available on this page for use with any page element.

Select All Elements

The Select multiple elements, if matched? setting controls if the action applies only to the first occurrence of the relative element selector or to all occurrences of it, if multiple exist.

Select NO if you want the action to apply only to the first occurrence. Select YES if you want the action to apply to all occurrences.

Re-Check for Elements

The Re-check for Elements setting enables or disables polling. If you enable polling, then Monetate continues to check for the selected element even if it does not initially appear on the page. This option is good if you have certain elements that don't fire right when the page loads.

If you disable polling, then Monetate only checks for the element once when the page loads.

Remove Attribute and Value

The Remove Attribute and Value toggle determines whether the action removes the specified attribute and its value instead of adding or modifying it.

If you select YES, then the action removes the specified attribute and any value it has from the selected element(s). If you select NO, then the action adds or modifies to the selected element(s) the attribute you specify.