hotdom

1.2.0 • Public • Published

🔥 hotdom

A lightweight library for DOM manipulation on modern browser using plain javascript.

Install

Requirements:

  • Node.js
  • npm (Node.js package manager)
npm install hotdom --save

OR

yarn add hotdom

usage

plug in your project

import dom from 'hotdom'

let el = dom.selectById(id);

dom.getAttributes(el)

Usage

Selector

selectByClass

const foo = dom.selectByClass('class-name');

addClass()

Add class on element

Takes three arguments, element, class and optional callback addClass(el, cls, callback)

const heading = dom.selectById('heading');

// add class 
dom.addClass(heading, 'common-heading');

findIn()

Find in children elements

Takes three arguments, element, css selector (class, id, tag and so on) findIn(el, selector)

const main = dom.selectById('main');

// find child element
dom.findIn(main, '.sub-main');

Utils

loadScript()

The loadScript() loads js file dynamically.

It returns promise.

Takes path-of-file as a argument and loads file dynamically.

Example:

import { loadScript } from 'hotdom'

// replace path with your own
loadScript('https://code.jquery.com/ui/1.12.1/jquery-ui.min.js)
 .then(() => {

 }).catch(() => console.error('Something went wrong.'));

getUrlParameter()

The getUrlParameter() returns value of matched key.

Takes key as a argument and returns value of matched key

Example:

import { getUrlParameter } from 'hotdom'

// https://foo.com/?name=hidy
const params = getUrlParameter('name'); // hidy

Documentation

Get started

Contributing

Create an issue if you find a bug or have a suggestion or question.

If you want to develop this project:

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

Package Sidebar

Install

npm i hotdom

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

9.5 kB

Total Files

7

Last publish

Collaborators

  • hidaytrahman