Created
April 26, 2018 20:49
-
-
Save gowhari/f327b20a00aead84697a481e3a4b5b70 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/cefasanure
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
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"></script><!DOCTYPE html> | |
<style id="jsbin-css"> | |
body { | |
background-color: #a04; | |
} | |
.vol-icon { | |
width: 32px; | |
height: 32px; | |
background-repeat: no-repeat; | |
} | |
.vol-0 { background-image: url(https://i.imgur.com/wZgLWGA.png) } | |
.vol-1 { background-image: url(https://i.imgur.com/oSv6akO.png) } | |
.vol-2 { background-image: url(https://i.imgur.com/rAoLkaw.png) } | |
.vol-3 { background-image: url(https://i.imgur.com/4I0XTWQ.png) } | |
</style> | |
</head> | |
<body> | |
<div class="vol-icon vol-0"></div> | |
<input type="range" class="slider" min="0" max="100" value="0" oninput="change_volume(this.value)"/> | |
<script id="jsbin-javascript"> | |
var change_volume = function(val) { | |
var cls = 'vol-' + (val == 0 ? 0 : val < 33 ? 1 : val < 66 ? 2 : 3); | |
var icon = $('.vol-icon'); | |
if (icon.hasClass(cls)) { return; } | |
icon.removeClass('vol-0 vol-1 vol-2 vol-3').addClass(cls); | |
}; | |
</script> | |
<script id="jsbin-source-html" type="text/html"><html> | |
<head> | |
<script src="https://code.jquery.com/jquery-3.1.0.js"><\/script><!DOCTYPE html> | |
</head> | |
<body> | |
<div class="vol-icon vol-0"></div> | |
<input type="range" class="slider" min="0" max="100" value="0" oninput="change_volume(this.value)"/> | |
</body> | |
</html> | |
</script> | |
<script id="jsbin-source-css" type="text/css">body { | |
background-color: #a04; | |
} | |
.vol-icon { | |
width: 32px; | |
height: 32px; | |
background-repeat: no-repeat; | |
} | |
.vol-0 { background-image: url(https://i.imgur.com/wZgLWGA.png) } | |
.vol-1 { background-image: url(https://i.imgur.com/oSv6akO.png) } | |
.vol-2 { background-image: url(https://i.imgur.com/rAoLkaw.png) } | |
.vol-3 { background-image: url(https://i.imgur.com/4I0XTWQ.png) } | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var change_volume = function(val) { | |
var cls = 'vol-' + (val == 0 ? 0 : val < 33 ? 1 : val < 66 ? 2 : 3); | |
var icon = $('.vol-icon'); | |
if (icon.hasClass(cls)) { return; } | |
icon.removeClass('vol-0 vol-1 vol-2 vol-3').addClass(cls); | |
}; | |
</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
body { | |
background-color: #a04; | |
} | |
.vol-icon { | |
width: 32px; | |
height: 32px; | |
background-repeat: no-repeat; | |
} | |
.vol-0 { background-image: url(https://i.imgur.com/wZgLWGA.png) } | |
.vol-1 { background-image: url(https://i.imgur.com/oSv6akO.png) } | |
.vol-2 { background-image: url(https://i.imgur.com/rAoLkaw.png) } | |
.vol-3 { background-image: url(https://i.imgur.com/4I0XTWQ.png) } |
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
var change_volume = function(val) { | |
var cls = 'vol-' + (val == 0 ? 0 : val < 33 ? 1 : val < 66 ? 2 : 3); | |
var icon = $('.vol-icon'); | |
if (icon.hasClass(cls)) { return; } | |
icon.removeClass('vol-0 vol-1 vol-2 vol-3').addClass(cls); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment