|
|
|
|
|
by WorldMaker
969 days ago
|
|
Mostly off the top of my head: document.getElementById('some-form').getElementsByTagName('input').forEach(i => i.classList.add('error'))
It is a little more verbose but it isn't that much more cumbersome today.That's also doing things "the right way" and not do-all selectors, but that option exists now, too: document.querySelectorAll('#some-form > input').forEach(i => i.classList.add('error'))
If you want to make it a little less verbose: const $ = document.querySelectorAll
const addClass = (className) => (item) => item.classList.add(className)
$('#some-form > input').forEach(addClass('error'))
|
|