I am utilizing an IosSlider that is functioning properly, but I am looking to enhance it by adding opacity to all images except for the selected image. This adjustment will make the selected image stand out more and enable users to focus on one image at a time. Below is the Javascript code for the IosSlider and Image Indicators:
<script>
$(window).load(function() {
$('.iosSlider').iosSlider({
desktopClickDrag: true,
onSlideChange: slideChange,
navNextSelector: $('.nextButton'),
navPrevSelector: $('.prevButton'),
infiniteSlider:true,
snapSlideCenter: true
});
});
function slideChange(args) {
try {
console.log('changed: ' + (args.currentSlideNumber - 1));
} catch(err) {
}
$('.indicators .item').removeClass('selected');
$('.indicators .item:eq(' + (args.currentSlideNumber - 1) + ')').addClass('selected');
}
</script>
Below is the HTML code:
<section id="slider" >
<div class="container-fluid">
<div class = 'responsiveHeight'>
<div class = 'inner'>
<div class = 'iosSlider'>
<div class = 'slider'>
<img class="item" src="../images/Project/Education-Municipal/grandcayman/01 0614-23.1491.1503.jpg"/>
<img class="item" src="../images/Project/Education-Municipal/grandcayman/02 0614-23_1350.jpg"/>
<img class="item" src="../images/Project/Education-Municipal/grandcayman/03 0614-23_DSC2008.jpg"/>
<img class="item" src="../images/Project/Education-Municipal/grandcayman/04 0614-23_DSC2130.jpg"/>
<img class="item" src="../images/Project/Education-Municipal/grandcayman/05 0614-23_G3A1975crop2.jpg"/>
</div>
</div>
</div>
<div class = 'prevButton'></div>
<div class = 'nextButton'></div>
</div>
</div> <!-- end container -->
<div class = 'indicators'>
<div class = 'item selected'></div>
<div class = 'item'></div>
<div class = 'item'></div>
<div class = 'item'></div>
<div class = 'item'></div>
</div>
I aim to adjust the opacity of all my slider images to 0.3, except the currently selected image, using CSS:
img {
opacity: .3;
}
img .item .selected{
opacity: 1;
}
While I lack proficiency in Javascript, I am exploring a straightforward method to achieve this goal through either CSS or Javascript. Thank you for your assistance. For further clarification, please refer to the example image illustrating what I intend to achieve: Desired slider result