hyTags
HomeHome DocumentationDocumentation

data-exists

Checks if a data attribute exists on an element
Parameter
Type
Description
name
String
The name of the data attribute to check (without the 'data-' prefix)
return
bool
True if the data attribute exists, false otherwise
Test Case:Check existing data attribute
    <div data-test="value"></div>
    
    <data-exists name="test">
    <assert-true>
    
    👆 Try to change something!
  • Test Case:Check non-existing data attribute
      <div></div>
      
      <data-exists name="missing">
      <assert-false>
      
      👆 Try to change something!
    • Test succeeded Test failed