[go: up one dir, main page]

@jimmymos/dom-helper

1.0.9 • Public • Published

@jimmymos/dom-helper

Give vanilla Javascript equivalent for Jquery popular functions

import { hasClass, addClass, removeClass, getParentsList, findParent } from "@jimmymos/dom-helper"

Does an element have a CSS class applied to it ?

// jQuery $('#el').hasClass('className')
hasClass(document.querySelector('#el'), 'className')

Add a CSS class to an element

// jQuery $('#el').addClass('className')
addClass(document.querySelector('#el'), 'className')

Remove a CSS class from an element

// jQuery $('#el').removeClass('className')
removeClass(document.querySelector('#el'), 'className')

Get the list of parents elements

// jQuery $('#el').parents()
getParentsList(document.querySelector('#el'))

Get the first parent matching a selector

// jQuery $('#el').parents('.className')
findParent(document.querySelector('#el'), '.className')

Package Sidebar

Install

npm i @jimmymos/dom-helper

Weekly Downloads

3

Version

1.0.9

License

ISC

Unpacked Size

4.06 kB

Total Files

5

Last publish

Collaborators

  • jimmymos