html - How to do mutiple css class in one line javascript code -
i have css class names - .exp-1 , .exp-2, .exp-3 , exp-4 ... there simple way write these in onlike line ,i m beginner javascript
document.getelementsbyclassname("exp-1")[0]; document.getelementsbyclassname("exp-2")[0]; document.getelementsbyclassname("exp-3")[0]; document.getelementsbyclassname("exp-4")[0];
to
document.getelementsbyclassname("exp-1,exp-2,exp-3, exp-4")[0];
you can use queryselector , use css selectors. returns first element of selected elements. if want return can use queryselectorall
document.queryselector(".exp-1,.exp-2,.exp-3,.exp-4");
Comments
Post a Comment