How to implement such a record? Let's say there is a function, while returning an element:
var $ = function (id) { if (id[0] == '#') { id = id.slice(1); } return document.getElementById (id); };
And there is a function that does something with this element:
var function bg (elem, color) { elem.style.backgroundColor = color; };
They are used like this:
bg($("id"), "цвет");
How to change these functions so that they work like in jquery:
$("id").bg("цвет");
I would also like to know how to make the ability to write a color change many times on the same element:
$("id").bg("цвет1").bg("цвет2").bg("цвет3") ...;