I gave my elements a class. I then run in javascript
document.getElementsByClassName("class").style.padding = "20px"
but it didin't work. Is the problem that in javascript padding doesn't work with classes?
I gave my elements a class. I then run in javascript
document.getElementsByClassName("class").style.padding = "20px"
but it didin't work. Is the problem that in javascript padding doesn't work with classes?
getElementsByClassName
returns an array-like object, so you either need to iterate over all of them in a loop, or specify the individual elements you want to change. It works when you change to an ID because ID's must be unique.
Ex:
var elems = document.getElementsByClassName('class');
Array.prototype.filter.call(elems, function(testElement){
testElement.style.padding = "80px"
});