Skip to content

Set HTML attribute

The Set HTML attribute configuration enables you to modify the value of any HTML attribute of an element.

How It works

  1. Select element: Start by choosing the element in the element panel to which you wish to apply this configuration.

  2. Setting up: Navigate to the right panel, in the properties section select the Set HTML attribute configuration.

  3. Specify the attribute key: Input the name of the HTML attribute you intend to modify (for example, src, href, etc.).

  4. Define the value: Use the Function Editor to specify the new value for the attribute. You can incorporate any data available in Wized, such as variables, cookies, request responses, or any other value.

  5. Add conditions (optional): If desired, you can include a condition in the Function Editor to modify the attribute only under specific circumstances.

Examples

  • Change a product image:

    • Attribute: src

    • value:

      javascript
      return r.getProduct.data.imageUrl; // Retrieves the image URL from the API response
  • Update a Button link:

    • Attribute: href

    • value:

      javascript
      return v.destinationPage; // Provides the URL stored in a variable
  • Enable or disable an input:

    • Attribute: disabled

    • value:

      javascript
      return !v.formularioValido; // Disables the input if the form is invalid