- This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I would like to not go through the animation if the link already has the class of “active”, I have been fooling with this for a bit and can’t seem to get it to work, this is the current jQuery I am using
// Scrolling Animation
$('#slides li a').each(function()
{
$('#slides li a').click(function(e)
{
$('#social').fadeOut(100);
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500,'easeInOutExpo',function()
{
$('#social').fadeIn(250);
});
e.preventDefault();
});
});
And here is the HTML
You would just need to wrap your click function in an if statement.
if( !$(this).hasClass('active') ) {
// click function
}
Ya, I had tried that, it doesn’t work, it’s still doing the animation.
// Scrolling Animation
$('#slides li a').each(function()
{
$('#slides li a').click(function(e)
{
if( !$(this).hasClass('active') ) {
$('#social').fadeOut(100);
var $anchor = $(this);
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top
}, 1500,'easeInOutExpo',function()
{
$('#social').fadeIn(250);
});
e.preventDefault();
}
});
});
What about that?
That worked, thanks!