element.classList
returns an array of classes, its my understanding .includes()
is used with arrays, so I don't understand why this wont work, I know I can use .contains() with classList but I'm curious as to why .includes() doesn't work.
both are arrays, if I typed this for example it wont work
var li=document.createElement('li');
li.classList.add('main-nav');
li.classList.includes('main-nav');
but this will
var ary=['a','b','c'];
ary.includes('a');
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…