I'm trying to make a function that works like this:
JavaScript:
let elm = document.querySelector('section')
elm.gridify();
assuming the function gridify adds display: grid;
to the element.
My question is: is that possible and, if so, how?
I tried this, and it's actually working:
function gridify() {
this.gridify = function(element) {
let myElement = document.querySelector(element)
myElement.setAttribute('style', 'display: grid;')
console.log(myElement);
}
}
var test = new gridify();
test.gridify('section');
Now, what I want is to make something like what I wrote above.