Get All Elements By ClassName and Change ClassName

前端 未结 5 2097
深忆病人
深忆病人 2020-11-29 08:59

I would like to...

  1. Scan the document for all elements that have a certain class name
  2. Perform some key functions on the innerHTML of that element
5条回答
  •  星月不相逢
    2020-11-29 09:50

    Another approach could be to use a selector:

    var arr = document.querySelectorAll('.exampleClass');
    for (var i=0;i

    Although it's not compatible with older browsers, it can do the trick as well if the webcontent is for modern browsers.

提交回复
热议问题