Using DOMmy.js top
Using DOMmy.js is very simple. You can find an exaustive documentation in the uncompressed version of DOMmy.js which is
all you need to work with the library in a matter of minutes.
However the following are some examples:
DOMReady tool:
// when the DOM is ready, execute fn
$$$( fn );
Selecting elements:
// select an element by ID
$('myel');
// select a collection of elements by css selector
$$('#myid div.myclass p');
Adding events to elements:
// add an event to an element
$('myel').on('click', function() {
log('Hey!');
});
// add a events to an element
$$('#myel p').on(
'click': function() {
log('Hey!');
},
'mouseout': function() {
log('Hey!');
}
});
Setting (and getting) properties to elements:
// set html
$('myel').html('new content');
// get an attribute
var title = $('myel').attr('title');
// set an attribute
$('myel').attr('title', 'my title');
// set attributes
$('myel').attr({'title': 'my title', 'alt': 'alternate text'});
Setting (and getting) css properties to elements:
// set css
$('myel').css('display', 'block');
// set multiple css
$('myel').css({'display': 'block', 'color': 'white'});
// get css
$('myel').css('display');
// get multiple css
$('myel').css(['display', 'color']);
Adding animations to elements:
// simple animation
$('myel').fx({'width': '300px'}, 2000, callBack);
// queue animations
$$('.myel').fx({'width': '300px'}, 2000, callBack, true);
.fx({'width': '300px'}, 2000, callBack, true);
Element storage:
// set storage
$('myel').set('myVal', myVal);
// multiple storage
$('myel').set({'myVal': myVal, 'mySecondVal': mySecondVal});
$$('div#a, div#b').set('prop', 10);
// get storage
$('myel').get('myVal');
$('a').get('prop'); // 10
Easy chain methods to collection of elements:
// multiple call
$$('#e, #d')
.fx({'font-size': '40px', 'color': 'yellow'}, 1)
.fx({'font-size': '10px', 'color': 'red'}, 1)
.attr('title', 'thed')
.attr('class', 'thed')
.attr({'lang': 'en', 'dir': 'ltr'});