再一次,我不擅長編碼(我沒有經驗)。HTML中的切換開關狀態列表
但是,在這個例子中,我想獲得一個切換開關列表的狀態。
我成功地製作了交換機列表。我怎樣才能得到他們的狀態。更準確地說,我需要一個逗號分隔的按鈕1,按鈕2,按鈕5(當按鈕1,按鈕2 &按鈕5被選中時)分隔的檢查項目列表。
<!DOCTYPE html>
<html>
<head>
<style>
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {display:none;}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body>
<h2>
<center>Smartwatch Tasks Toggle</center>
</h2>
<table style="width:100%">
<tr>
<td>Switch 1</td>
<td><label class="switch">
<id name="Switch 1">
<input type="checkbox" unchecked>
<span class="slider round"></span>
</label></td>
</tr>
<tr>
<td>Switch 2</td>
<td><label class="switch">
<id name="Switch 2">
<input type="checkbox" unchecked>
<span class="slider round"></span>
</label></td>
</tr>
<tr>
<td>Switch 3</td>
<td><label class="switch">
<id name="Switch 3">
<input type="checkbox" unchecked>
<span class="slider round"></span>
</label></td>
</tr>
<tr>
<td>Switch 4</td>
<td><label class="switch">
<id name="Switch 4">
<input type="checkbox" unchecked>
<span class="slider round"></span>
</label></td>
</tr>
<tr>
<td>Switch 5</td>
<td><label class="switch">
<id name="Switch 5">
<input type="checkbox" unchecked>
<span class="slider round"></span>
</label></td>
</tr>
</table>
<br><br>
<button type="button" onclick="alert('Hello world!')">Save</button>
<br><br>
<button type="button" onclick="alert('Hello world!')">Cancel</button>
</body>
</html>
你可以使用jQuery嗎? –