I attempting to make a website which would have a slider that which the websites user could slide to set a specific date. Under the slider I am planning to have a map on which markers would appear/move/disappear depending on where the slider is located. So far, with the help of this great community here (RobG specifically), I have a working slider, a map and pretty much everything else except I can't find a way how to make these markers or icons or text appear in the website depending on the position of the slider.
For an example of the slider look here: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_rangeslider
How can I make things appear or dissapear on the website depending on the slider?
Edit for Aditya Prakash. Here is the full code with the scripts I tried to add:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.slidecontainer {
width: 100%;
}
.slider {
-webkit-appearance: none;
width: 100%;
height: 25px;
background: #d3d3d3;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
.slider:hover {
opacity: 1;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 25px;
height: 25px;
background: #4CAF50;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 25px;
height: 25px;
background: #4CAF50;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Custom Range Slider</h1>
<div class="slidecontainer">
<p>Default range slider:</p>
<input type="range" min="1" max="100" value="50">
<p>Custom range slider:</p>
<input type="range" min="0" max="1" value="0.5" class="slider" id="myRange" step="0.1">
</div>
<script>
myRange.onchange=function() {
var fader = document.getElementById('myRange');
document.getElementById('https://www.mapsofindia.com/worldmap/map-of-world.jpg').style.opacity = fader.value;
}
</script>
</body>
</html>
You can add the following script to make it work
<script>
myRange.onchange=function() {
var fader = document.getElementById('myRange');
document.getElementById('pic').style.opacity = fader.value;
}
</script>
The 'pic' ID will be the ID of the image.
Edit: You will also need to change the value of your slider to range from 0 to 1. Use the following line.
<input type="range" min="0" max="1" value="0.5" class="slider" id="myRange" step="0.1">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.