4.1.0 • Published 5 years ago
lit-selector v4.1.0
LitSelector
Usage
To include LitSelector, install with npm.
npm i lit-selector
CDN
https://cdn.jsdelivr.net/npm/lit-selector/index.min.js
Examples
Finding the first element matching a class
const el = ls(".myclass");
A more complex selector
const el = ls("div.user-panel.main input[name='login']");
Obtaining a list of matches
const container = ls("#test");
const matches = container.ls("div.highlighted > p");
Accessing the matches
Otherwise, you can simply use standard array notation to access the contents of the list. You can use any common looping statement, such as:
const users = ls(".users");
users.forEach(userItem => console.log(userItem));