Как изменить состояние текста с помощью флажка [дубликат]CSS

Разбираемся в CSS
Ответить
Anonymous
 Как изменить состояние текста с помощью флажка [дубликат]

Сообщение Anonymous »


I am using a checkbox and styles to create a toggle switch. Currently, I need it to display the initial state as "off" when the page loads, and after clicking, it should change to "on". Similarly, when turned off, it should return to the previous position.

In addition, the on/off values should have different colors, so appropriate classes should be provided for them.

Below is an example of my code, I would appreciate any recommendations.

function ch_mode() { var toggle_state = document.getElementById('myCheck'); var check = document.getElementById('s_mode'); var another = document.getElementById('from'); var on = "on"; var off = "off"; if (toggle_state.checked) { another.innerText = on; } else { another.innerText = "OFF"; } } mode: OFF


Источник: https://stackoverflow.com/questions/781 ... g-checkbox
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «CSS»