I am wanting when I click on the 3rd button, the 1st and 2nd buttons will automatically turn off. On the contrary, when I click on the 2nd button, the 1st and 3rd buttons will automatically switch to off
HTML:
div {
color: red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="tg">
<thead>
<tr>
<th class="tg-6nwz"></th>
<th class="tg-baqh">Colum 1</th>
<th class="tg-baqh">Colum 2</th>
<th class="tg-baqh">Colum 3</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-c3ow">TH01</td>
<td class="tg-c3ow smtp-01">
<label class="switch">
<input type="checkbox" checked="checked">
<span class="slider round"></span>
</label>
</td>
<td class="tg-c3ow smtp-02">
<label class="switch">
<input type="checkbox" checked="checked">
<span class="slider round"></span>
</label>
</td>
<td class="tg-c3ow smtp-03">
<label class="switch">
<input type="checkbox" checked="checked">
<span class="slider round"></span>
</label>
</td>
</tr>
</tbody>
</table>
<div id="log"></div>
3
Answers
Something like this:
I would use radio buttons and simple CSS styling for the toggle buttons (no need for JavaScript) – something like:
PS. IMO I find the toggle confusing for this scenario I would expect checkbox behavior (individual/unrelated).
Update I’ve changed the code to show toggle styling works on both radio and checkbox.
Update I’ve added a small script to toggle checkboxes within the same table row