У меня есть несколько флажков, и каждому флажку присвоено либо значение="0", либо значение="1". Я хочу проверить каждый флажок; если флажок имеет значение = «0», цвет текста этого флажка должен измениться на красный. Я написал следующий код:const allCheckboxes = document.querySelectorAll('input[type="checkbox"]');
for (let k = 0; k < allCheckboxes.length; k++) {
const checkbox = allCheckboxes[k];
if (checkbox.value === "0") {
checkbox.parentNode.style.color = "red";
}
}
Когда я запускаю функцию, цвет текста всех флажков меняется на красный. Даже если я изменю «0» на «1», результат не изменится.
Пожалуйста, расскажите мне причину и как это исправить.
Это CSS. р>
.correct-answer {
color: red;
}
Это HTML
Question 1: A ball is dropped from a height of 5.00 m and completely elastically collides with the ground (the rebound speed from the ground is equal to the speed just before hitting the ground). Assume that mechanical energy is not lost due to air resistance. Take $g = 10\ \text{m/s}^2$.
a) The motion of the ball is simple harmonic motion.
b) The speed of the ball when it hits the ground is $10\ \text{m/s}$.
c) The motion of the ball is periodic.
d) The period of the ball's motion is $1\ \text{s}$.
Question 2: An object oscillates harmonically; it takes 0.25 seconds to move from a point with zero velocity to the next point with zero velocity. The distance between these two points is 36 cm. Calculate (a) the period, (b) the frequency, and (c) the amplitude of the motion.
a) The period of the oscillation is 0.5 s.
b) The amplitude of the oscillation is 36 cm.
c) The maximum speed of the object is 226.19 cm/s.
d) The maximum distance the object can travel in 0.125 s is 18 cm.
Подробнее здесь: https://stackoverflow.com/questions/791 ... -checkboxe
Управление состояниями флажков в массиве JavaScript без влияния на другие флажки ⇐ CSS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Управление состояниями флажков в массиве JavaScript без влияния на другие флажки
Anonymous » » в форуме CSS - 0 Ответы
- 22 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Проблема с выравниванием флажков Vue.js: центрирование флажков внутри ячеек таблицы
Anonymous » » в форуме CSS - 0 Ответы
- 92 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Проблема с выравниванием флажков Vue.js: центрирование флажков внутри ячеек таблицы
Anonymous » » в форуме CSS - 0 Ответы
- 69 Просмотры
-
Последнее сообщение Anonymous
-