hyTags
HomeHome DocumentationDocumentation

data-set

Sets the value of a data attribute on an element
Parameter
Type
Description
name
String
The name of the data attribute (without the 'data-' prefix)
value
String
The value to set for the data attribute
return
void
No return value
Test Case:Set data attribute
    <div></div>
    
    <data-set name="value" value="world">
    <data-get name="value">
    <assert-equal value="world" type="string">
    
    👆 Try to change something!
  • Test Case:Overwrite existing data attribute
      <div data-test="old"></div>
      
      <data-set name="test" value="new">
      <data-get name="test">
      <assert-equal value="new" type="string">
      
      👆 Try to change something!
    • Test succeeded Test failed