Skip to content

bezborodow/element-loaded-by-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elementLoadedById()

elementLoadedById():

Detect when an element matching an ID is loaded into the DOM.

Synopsis

import elementLoadedById from 'element-loaded-by-id';

elementLoadedById(id).then(element => {
    // Do something...
});

Installation

npm i element-loaded-by-id

Example

See example.

Syntax

elementLoadedById(id)

Parameters

id: A unique ID for the element.

Return Value

A Promise that is:

  • Already fulfilled, if the element is found already loaded into the document.
  • Already rejected, if the element was not found and the DOM has already finished loading.
  • Asynchronously fulfilled, when a mutation occurs that adds the element into the DOM.
  • Asynchronously rejected, when the DOM has finished loading and the element has not been found.

Description

elementLoadedById() will search the document for the element by ID. It will continue searching until the DOM has finished loading (DOMContentLoaded event).

See also:

About

Promise for when an element matching an ID is loaded into the DOM.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published