Logos DX
    Preparing search index...

    Function attr

    • Set or get HTML attributes on one or more elements.

      Provides a unified interface for attribute manipulation, mirroring the css() pattern with .remove() and .has() methods.

      Parameters

      Returns void

      attr(el, { 'data-id': '123', role: 'button' });
      attr(el, 'role'); // → 'button'
      attr(el, ['role', 'data-id']); // → { role: 'button', 'data-id': '123' }
      attr.remove(el, 'role');
      attr.has(el, 'disabled'); // → boolean
    • Set or get HTML attributes on one or more elements.

      Provides a unified interface for attribute manipulation, mirroring the css() pattern with .remove() and .has() methods.

      Parameters

      Returns string | null

      attr(el, { 'data-id': '123', role: 'button' });
      attr(el, 'role'); // → 'button'
      attr(el, ['role', 'data-id']); // → { role: 'button', 'data-id': '123' }
      attr.remove(el, 'role');
      attr.has(el, 'disabled'); // → boolean
    • Set or get HTML attributes on one or more elements.

      Provides a unified interface for attribute manipulation, mirroring the css() pattern with .remove() and .has() methods.

      Parameters

      Returns Record<string, string | null>

      attr(el, { 'data-id': '123', role: 'button' });
      attr(el, 'role'); // → 'button'
      attr(el, ['role', 'data-id']); // → { role: 'button', 'data-id': '123' }
      attr.remove(el, 'role');
      attr.has(el, 'disabled'); // → boolean
    Index

    Methods

    Methods

    • Check whether an element has a specific attribute.

      Parameters

      Returns boolean

      attr.has(el, 'disabled'); // → true
      
    • Remove one or more attributes from one or more elements.

      Parameters

      Returns void

      attr.remove(el, ['role', 'data-id']);
      attr.remove([el1, el2], 'role');