Skip to content
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.

Latest commit

 

History

History
48 lines (31 loc) · 878 Bytes

el.md

File metadata and controls

48 lines (31 loc) · 878 Bytes

DOM/el()

This function translates a variety of input types to an element. You can supply a CSS selector or an HTML markup and get an HTMLElement in return.

Import

import el from '@web-native-js/play-ui/src/dom/el.js';

Syntax

el(input);

Parameters

  • input - String|HTMLElement: A valid CSS selector, HTML markup or an instance of HTMLElement. If a selector is provided, only the first-matched element is returned.

Return

  • HTMLElement - The resulting DOM element.
  • NULL - Where input is a CSS selector but matches no element.

Usage

In the example below, we are calling this function with a CSS selector.

<body>

  <header>
    <div>DIV1</div>
  </header>

  <main>
    <div>DIV2</div>
  </main>

</body>
let div = el('div');
console.log(div.innerText); // DIV1