You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HTML is a small, extensible library to help you use the DOM in a simpler, more direct way.
See here for a demo, more information and documentation.
Thanks to Adrian Cooney for the inspiration and starting point for this project.
// direct traversalvarurl=HTML.body.div.header.h1.a.href;// easy, contextual searchHTML.body.find("#title a").textContent="New title!";// an each() function to use the selected node or nodesHTML.body.section.ul.li.each(function(li,i){li.a.textContent="Link #"+i;});// an only() function to narrow your selectionvarlist=HTML.find('li');list.only(4).classList.add('highlighted');// by indexlist.only(0,4).classList.remove('highlighted');// by slicelist.only('.highlighted').style.fontStyle='italic';// by selectorlist.only(function(l,i){returni%2;}).textContent+='Odd';// by function
Extensions
The [minified][all] version automatically includes
find(),each(),only(),add()andremove() (so far).
The one "official" extensions (so far) is:
// use simple expressions with `add()` ([emmet][emmet] w/o grouping or numbering)varcontent=HTML.body.add('div>section*5>p>').each(function(p){p.textContext="Hello world!";});
Release History
2013-08-01 v0.9.0 (estimated first release)
About
A simple, extensible way to work directly with the DOM.