Function attr

  • Returns an object that lazily represents an attribute with the name within the treespace element (or document). Getting properties returns the attribute in the specified element and setting or deleting properties updates or removes the attribute correspondingly.

    Parameters

    • name: string
    • Optional treespace: Element

    Returns any

    Example

    import { attr } from 'apption';
    document.body.innerHTML = `
    <div>I am a div</div>
    <p class="main">I am a paragraph</p>
    <section>I am a section</section>
    <article>I am an article</article>
    `;
    const slct = attr('class', document.body);
    console.log(slct.p); // main