我想知道在JavaScript中选择元素的两种不同的语法。假设如果我想从当前文档中选择所有div,那么:console.log("There are "+divs.length+" Divs in Document !")但也有另一种方法,比如:
var divs = document.querySele
我希望做以下工作,但不确定如何正确地利用.startsWith中的目标内容。divClass.startsWith('example')){ }
如上文所示,我尝试在divClass上使用divClass,但没有使用。.classList.add()将类应用到带有示例类的所有div中。所有解决方案请使用香草JavaScript (No j