📅  最后修改于: 2022-03-11 15:01:24.784000             🧑  作者: Mango
// Add class 'hide' to every child div on 1st child lvl
var el = document.getElementById('your-element-id');
var classList = 'classList' in el;
for (var i = 0; i < el.children.length; i++) {
var child = el.children[i];
if (child.tagName == 'DIV') {
if (classList) {
child.classList.add('hide');
} else {
child.className += ' hide'
}}}