A little library to manipulate the dom
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
dom.js
package.json

README.md

dom

A little library to manipulate the dom

parse

jstiller.components.dom.parse('<div><p>text</p></div><button>button</button>');

insert

element

var existingNode = jstiller.components.dom.find('body').firstChild,
    newNode = jstiller.components.dom.create.element('div');

jstiller.components.dom.insert.element(newNode).before(existingNode);
var existingNode = jstiller.components.dom.find('body').firstChild,
    newNode = jstiller.components.dom.create.element('div');

jstiller.components.dom.insert.element(newNode).after(existingNode);
var existingNode = jstiller.components.dom.find('body').firstChild,
    newNode = jstiller.components.dom.create.element('div');

jstiller.components.dom.insert.element(newNode).into(existingNode);

className

var existingNode = jstiller.components.dom.create.element('div');

jstiller.components.dom.insert.className('class').to(existingNode);

text

var existingNode = jstiller.components.dom.create.element('div');

jstiller.components.dom.insert.text('text ...').before(existingNode);
var existingNode = jstiller.components.dom.create.element('div');

jstiller.components.dom.insert.text('text ...').after(existingNode);
var existingNode = jstiller.components.dom.create.element('div');

jstiller.components.dom.insert.text('text ...').into(existingNode);

replace

element

var mainNode = jstiller.components.dom.find('main'),
  newMainNode = jstiller.components.dom.find('main');

jstiller.components.dom.replace.element(mainNode).by(newMainNode);

text

var mainNode = jstiller.components.dom.find('main');

jstiller.components.dom.replace.text('text ...').of(mainNode);

remove

element

var mainNode = jstiller.components.dom.find('main');
jstiller.components.dom.remove.element(mainNode);

className

var mainNode = jstiller.components.dom.find('main');
jstiller.components.dom.remove.className('class').from(mainNode);

create

element

var mainNode = jstiller.components.dom.create.element('div', {
  align: 'left'
});

find

var mainNode = jstiller.components.dom.find('main');
var mainNode = jstiller.components.dom.find('main', {
  quantity: 'all'
});
var mainNode = jstiller.components.dom.find('main', {
  context: document,
});
var mainNode = jstiller.components.dom.find('main', {
  quantity: 'one',
  context: document,
});