Utilizing the liquidslider script on my website, I have created a slider with the following HTML code:
<div class="liquid-slider" id="slider-id">
<div>
<h2 class="title">Slide 1</h2>
// Content goes here
</div>
<div>
<h2 class="title">Slide 2</h2>
// Content goes here
</div>
<div>
<h2 class="title">Slide 3</h2>
// Content goes here
</div>
</div>
The current JavaScript being used is as follows:
$('#slider-1').liquidSlider({
autoHeight:false,
slideEaseFunction:'animate.css',
slideEaseDuration:1000,
heightEaseDuration:1000,
animateIn:"fadeIn",
animateOut:"fadeOut",
callback: function() {
var self = this;
$('.slider-1-panel').each(function() {
$(this).removeClass('animated ' + self.options.animateIn);
});
$('.slider-1-panel').each(function() {
alert("you opened panel");
});
}
});
The message "you opened panel" is displayed multiple times when the user clicks on the panel tab. To show the message only once for each panel, how can we make that change? Additionally, animations will be added to each panel via CSS and knowing when the user selects a panel is crucial.
A jsfiddle has been created with added resources, although it's not fully functional yet. The visible CSS code might provide some insight.
EDIT: More details have been included. An option has been implemented to change all tabs when any tab is clicked:
$('#slider-1').liquidSlider({
autoHeight:false,
slideEaseFunction:'animate.css',
slideEaseDuration:1000,
heightEaseDuration:1000,
animateIn:"fadeIn",
animateOut:"fadeOut",
callback: function() {
var self = this;
$('.slider-1-panel').each(function() {
$(this).removeClass('animated ' + self.options.animateIn);
});
$('#slider-1-nav-ul a').each(function() {
$(this).css('background', '#'+Math.floor(Math.random()*16777215).toString(16));
$(this).css('color', '#'+Math.floor(Math.random()*16777215).toString(16));
})
}
});
Now, the goal is to modify the
$('#slider-1-nav-ul a').each(function() {
part to target only the clicked tab instead of all tabs. How can this be achieved?