JSFiddle - React, Tailwind, and code Playground
by techiedelight
HTML
<!doctype html>
<html>
<body>
<p>Choose your gender:</p>
<div>
<input type="checkbox" id="male" name="gender" value="male" checked>
<label for="male">male</label>
</div>
<div>
<input type="checkbox" id="female" name="gender" value="female">
<label for="female">female</label>
</div>
<div>
<button id="submit">Get Value</button>
</div>
<br>
</body>
</html>
CSS
p,
label {
font: 15px 'Exo 2', sans-serif;
}
input {
margin: 6px;
}
button {
margin-top: 10px;
padding: 2 2;
font: 15px 'Exo 2', sans-serif;
}
JavaScript
$(document).ready(function() {
$('#submit').click(function() {
alert($("input[type=checkbox][name=gender]:checked").val());
})
});