dom-maker
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

dom-maker

A library for create element by VanillaJs easily

install

npm install dom-maker
#
yarn add dom-maker

useage

import $ from 'dom-maker';

const dom = $('div')
  .setAttr('data-type', 'img-box')
  .addChildren([
    $('div')
      .addClass('left-area')
      .addChildren([
        $('img')
          .addClass('img cover')
          .setAttr('draggable', false)
          .setAttr('src', 'https://source.unsplash.com/8xznAGy4HcY/800x400'),
      ]),
    $('div')
      .addClass('right-area')
      .addChildren([
        $('div').addClass('title').setText('title'),
        $('div').addClass('href').setText('href'),
      ]),
  ])
  .getElm();

// equal to

// <div data-type="img-box">
//   <div class="left-area">
//     <img src="https://source.unsplash.com/8xznAGy4HcY/" draggable="flase" class="img cover">
//   </div>
//   <div class="left-area">
//     <div class="title">title</div>
//     <div class="href">href</div>
//   </div>
// </div>

document.body.append(dom);

Package Sidebar

Install

npm i dom-maker

Weekly Downloads

0

Version

0.0.8

License

MIT

Unpacked Size

258 kB

Total Files

12

Last publish

Collaborators

  • fog3211