in jQuery you can do this:
$('#myElement').addClass('header');
how can I make it like this in pure javascript
var elem = document.getElementById('myElement');
elem.addClass('header');
So I want to make a small custom library which use the selector before the function instead of this:
function addClass(element, class) {
element.className += ' ' + class;
}
which is called like this:
var elem = document.getElementById('myElement');
addClass(elem, 'header');
Is this possible and if it is how can I do that?