I'm wondering if there's a way to create an array of dom elements where all elements can have a particular css, and have the option for one element at a time to not have this class?
For instance I have 2 divs and each has one css class called outer-div
and the class I want a single instance to be able to not have is minimized
that can be applied in addition to outer-div
.
Right Now, I have this javascript:
function oneWindow(){
var windowList = document.getElementsByClassName('outer-div');
console.log(windowList);
var openList = new Array();
if(windowList.length>0){
for(var i = 0; i<windowList.length; i++){
if(windowList[i].className.indexOf('minimize')==-1){
openList.push(windowList[i]);
}
}
}
if(openList.length>1){
for(var j=1; j<openList.length; j++){
openList[j].className += ' minimize';
}
}
else if(openList.length<1){
for(var t=0; t<windowList.length; t++){
//not sure what to put here but should allow one element to not have minimize
}
}
}
So in short, I want to allow one Element in the windowList
to not have minimize
but allow all elements to be able to have minimize
and all have the ability to become the single element without minimize
.
By The Way, I have to use pure javascript and not jquery.