I have On/Off switcher in my web project :
HTML:
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox"
id="myonoffswitch" checked>
<label class="onoffswitch-label" for="myonoffswitch">
<span #onoffswitch class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
CSS:
.onoffswitch-inner:before {
content: "ON";
padding-left: 10px;
background-color: #93297E; color: #FFFFFF;
}
.onoffswitch-inner:after {
content: "OFF";
padding-right: 10px;
background-color: #EEEEEE; color: #999999;
text-align: right;
}
I want to know if the switcher is turned ON or OFF, I tried to get the value, using the next code, but it does not work:
getSwitcherValue(onoffswitch) {
console.log("onoffswitch:"+onoffswitch.style.content);
}
Do you have any ideas how to get the value of on/off switcher?
Aucun commentaire:
Enregistrer un commentaire