I copied and adapted this toggleable switch off w3schools and the major change I made is the text that changes when toggled. How can I access the value of the text ('1x' and '2x') in my javascript file for an if statement (this can be also a console log just as an example)? I'm still new to CSS and HTML.
.switch{
position: relative;
display: inline-block;
top: 33.75%;
left: 35%;
width: 148px;
height: 37.5px;
z-index: 1;
border-width: 5px;
/* visibility: hidden; */
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #10185c;
border-radius: 5px;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 29px;
width: 29px;
left: 4px;
bottom: 4px;
background-color: white;
color:#050A30;
font-size: 18px;
text-align: center;
content: '1x';
border-radius: 5px;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #1e2a82;
}
input:checked + .slider:before {
-webkit-transform: translateX(112px);
-ms-transform: translateX(112px);
transform: translateX(112px);
content: '2x';
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<label class="switch">
<input type="checkbox">
<span class="slider"></span>
</label>
<script src="script.js"></script>
</body>
</html>