Welcome to super simpliest wrapper library to type less code!
npm install by-el
import React from 'react';
import ReactDOM from 'react-dom';
import { byId } from 'by-el';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
byId('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
Import wrapper functions:
import {
byId,
byClass,
bySelector,
byTag,
byName,
byAll
} from 'by-el`;
to select element by id:
byId("element-id");
// specific parent
byId("element-id", parentElement);
to select element by selector:
bySelector("#element-id");
bySelector(".class");
bySelector("tag");
//specific parent
bySelector(".class", byId("element-id"));
to select elements by className:
byClass("class");
//specific parent
byClass("class", bySelector("tag"));
to select elements by Name:
byName("name");
//specific parent
byName("name", bySelector("tag"));
to select elements by TagName:
byTag("tag");
//specific parent
byTag("tag", bySelector("#element-id"));
to select elements by all:
byAll(".class");
//specific parent
byAll(".class", byId("element-id"));