У меня есть несколько флажков, и каждому флажку присвоено либо значение="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
Разбираемся в CSS
1730619447
Anonymous
У меня есть несколько флажков, и каждому флажку присвоено либо значение="0", либо значение="1". Я хочу проверить каждый флажок; если флажок имеет значение = «0», цвет текста этого флажка должен измениться на красный. Я написал следующий код:[b]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:[/b] 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$.
[b]
a)[/b] The motion of the ball is simple harmonic motion.[b]
b)[/b] The speed of the ball when it hits the ground is $10\ \text{m/s}$.[b]
c)[/b] The motion of the ball is periodic.[b]
d)[/b] The period of the ball's motion is $1\ \text{s}$.[b]
Question 2:[/b] 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.
[b]
a)[/b] The period of the oscillation is 0.5 s.[b]
b)[/b] The amplitude of the oscillation is 36 cm.[b]
c)[/b] The maximum speed of the object is 226.19 cm/s.[b]
d)[/b] The maximum distance the object can travel in 0.125 s is 18 cm.
Подробнее здесь: [url]https://stackoverflow.com/questions/79152221/managing-checkbox-states-in-a-javascript-array-without-impacting-other-checkboxe[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия