For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
    • Element Properties & Methods
    • Element Types & Methods
      • Element Presets
      • DOM Elements
        • Get HTML Tag
        • Set HTML Tag
        • Get All Attributes
        • Get Attribute
        • Set Attribute
        • Remove Attribute
      • Strings
      • Components
      • Slots
      • Headings
      • Images
      • Links
      • Forms
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • element.getAttribute(name)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
ElementsElement Types & MethodsDOM Elements

Get Attribute

Was this page helpful?
Previous

Set Attribute

Next
Built with

element.getAttribute(name)

Retrieve the value of the named HTML attribute of the DOMElement. Use this method instead of the ‘Custom Attribute’ methods.

Syntax

1element.getAttribute(name: string): Promise<null | string>

Parameters

  • name : string - The name of the attribute

Returns

  • Promise<String>: A promise that resolves to the value of the named HTML attribute for the DOMElement.
  • Promise<null>: If the attribute doesn’t exist, this method will return null.

Example

1// Get All Elements and find first DOM Element
2const elements = await webflow.getAllElements()
3const DOMElement = elements.find(element => element.type === "DOM")
4
5if (DOMElement?.type === "DOM") {
6
7 // Get DOM Element's Attribute by Name
8 const attribute = await DOMElement.getAttribute("MyAttribute")
9 console.log(attribute)
10
11} else {
12 console.log('No DOM Element Found')
13}

Designer Ability

Checks for authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canAccessCanvasAnyAnyAnyAny