frontend-challenges
frontend-challenges copied to clipboard
480 - jQuery.css - javascript
index.js
/**
* Simple DOM wrapper with method chaining support.
* @param {string} selector - CSS selector
* @returns {object} wrapper with chainable methods
*/
function $(selector) {
const nodeList = document.querySelectorAll(selector);
return {
css (property, value) {
nodeList.forEach(node => {
node.style[property] = value;
})
return this;
}
}
}
export { $ };