hyTags
HomeHome DocumentationDocumentation

data-get

Gets the value of a data attribute from an element
Parameter
Type
Description
name
String
The name of the data attribute (without the 'data-' prefix)
return
string
The value of the data attribute, or nil if it doesn't exist
Test Case:Get existing data attribute
    <div data-test="hello"></div>
    
    <data-get name="test">
    <assert-equal value="hello" type="string">
    
    👆 Try to change something!
  • Test Case:Get non-existing data attribute returns nil
      <div></div>
      
      <data-get name="missing">
      <value-is-nil>
      <assert-true>
      
      👆 Try to change something!
    • Test succeeded Test failed