Created
September 19, 2017 18:07
-
-
Save rob0t7/36da61d77a7c3403497e192c04f087e6 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kibonaj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.checkbox { | |
display: block; | |
cursor: pointer; | |
} | |
.checkbox__input { | |
display: none; | |
} | |
.checkbox__box { | |
display: inline-block; | |
width: 30px; | |
height: 30px; | |
border: 2px solid lightgreen; | |
transition: background-color 0.5s ease; | |
} | |
.checkbox:hover .checkbox__box, | |
.checkbox__input:checked + .checkbox__box { | |
background: lightgreen; | |
} | |
.checkbox__input:checked:hover + .checkbox__box { | |
background: none; | |
} | |
</style> | |
</head> | |
<body> | |
<label class="checkbox"> | |
<input class="checkbox__input" type="checkbox" name="foo" value="1"> | |
<div class="checkbox__box"></div> | |
Click Me | |
</label> | |
<label class="checkbox"> | |
<input class="checkbox__input" type="checkbox" name="foo" value="1"> | |
<div class="checkbox__box"></div> | |
Click Me | |
</label> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script> | |
<script id="jsbin-javascript"> | |
$('.checkbox__input').on('click', (ev) => { | |
if (ev.target.checked) { | |
console.log('checked') | |
} else { | |
console.log('unchecked') | |
} | |
}) | |
</script> | |
<script id="jsbin-source-css" type="text/css">.checkbox { | |
display: block; | |
cursor: pointer; | |
} | |
.checkbox__input { | |
display: none; | |
} | |
.checkbox__box { | |
display: inline-block; | |
width: 30px; | |
height: 30px; | |
border: 2px solid lightgreen; | |
transition: background-color 0.5s ease; | |
} | |
.checkbox:hover .checkbox__box, | |
.checkbox__input:checked + .checkbox__box { | |
background: lightgreen; | |
} | |
.checkbox__input:checked:hover + .checkbox__box { | |
background: none; | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">$('.checkbox__input').on('click', (ev) => { | |
if (ev.target.checked) { | |
console.log('checked') | |
} else { | |
console.log('unchecked') | |
} | |
})</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.checkbox { | |
display: block; | |
cursor: pointer; | |
} | |
.checkbox__input { | |
display: none; | |
} | |
.checkbox__box { | |
display: inline-block; | |
width: 30px; | |
height: 30px; | |
border: 2px solid lightgreen; | |
transition: background-color 0.5s ease; | |
} | |
.checkbox:hover .checkbox__box, | |
.checkbox__input:checked + .checkbox__box { | |
background: lightgreen; | |
} | |
.checkbox__input:checked:hover + .checkbox__box { | |
background: none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.checkbox__input').on('click', (ev) => { | |
if (ev.target.checked) { | |
console.log('checked') | |
} else { | |
console.log('unchecked') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment