JSPM

light-dom-selector

0.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q11662F
  • License MIT

Extra lightweight DOM selector helper

Package Exports

  • light-dom-selector

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (light-dom-selector) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

light-dom-selector npm downloads GitHub license npm version

Lightweight dom selector by simple symbols that outputs an SelectorFn instance.

Support Version IE 6+

Install

npm install light-dom-selector
// This module is only offered as a ES Module
import $ from "light-dom-selector";

// Common JS
const $ = require("light-dom-selector")

Select Dom

Note: if the dom is not exist, {element: undefined, constructor: Object} this is the result.

getElementById

$("#app")
// => SelectorFn {element: Element, constructor: Object}

getElementsByClassName

$(".app")
// => SelectorFn {element: Element, constructor: Object}

querySelectorAll

$("*.app h1")
// => SelectorFn {element: Element, constructor: Object}

getElementsByName

$("~h1")
// => SelectorFn {element: Element, constructor: Object}

getElementsByTagName

$("@app")
// => SelectorFn {element: Element, constructor: Object}

Event

on

you can create event by on method.

$("#app").on("click", function() {
  /// event
});

$("#app").on("click mouseover", function() {
  /// event
});

remove event by off method.

function clickFn() {
    console.log(this);
}
$("#app").on("click", clickFn); // addEventListener

$("#app").off("click", clickFn); // removeEventListener