Skip to content

Instantly share code, notes, and snippets.

@gowhari
Created April 26, 2018 20:49
Show Gist options
  • Save gowhari/f327b20a00aead84697a481e3a4b5b70 to your computer and use it in GitHub Desktop.
Save gowhari/f327b20a00aead84697a481e3a4b5b70 to your computer and use it in GitHub Desktop.
<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>
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) }
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