Skip to content

🖱 A JavaScript library for interactively picking DOM elements

License

Notifications You must be signed in to change notification settings

cesaryuan/pick-dom-element

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pick-dom-element

npm version

A JavaScript library (written in TypeScript) for interactively picking DOM elements.

Usage

Create an instance of the ElementPicker class, and call its start() method to start picking. Provide an onHover or onClick callback to get the picked element(s). Call stop() to stop picking and remove the overlay from the DOM.

import { ElementPicker } from "pick-dom-element";

const picker = new ElementPicker();
picker.start({
  onHover: (el) => console.log(`Hover: ${el}`),
  onClick: (el) => {
    picker.stop();
    console.log(`Picked: ${el}`);
  },
});

See the example directory for a more complete example of how to use the library.

About

🖱 A JavaScript library for interactively picking DOM elements

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 77.5%
  • JavaScript 13.9%
  • HTML 8.6%