Junior — Middle+
Creating chainable methods for working with DOM elements
livecode
Task condition
It is necessary to implement a function $ that will return an object supporting method chaining for manipulating the selected element. The addClass method should add the specified CSS class, html — insert the given HTML code inside the element, toggleClass — toggle the presence of a class, and css — accept an object with styles and apply them to the element. All methods should return the same object so that they can be called sequentially.
import "./helpers";
function $(selector) {
//code here
}
// example usage
// const $node = $(".js-node");
// $node.addClass("bordered").html("<li>hello</li>").toggleClass("disabled").css({
// color: "green",
// padding: "10px"
// });