I've got this code that goes through all my internal href
s but I can't see to be able to figure out how to create an exception for one of the links that links to the div #section1
. I need some kind of if
statement surrounding the section.addClass("active");
line but I don't know which conditions to use to achieve this. Can you help?
Code: http://jsfiddle.net/vD3vP/
if (scrolledTo > target - threshold && scrolledTo < target + threshold) {
//remove all selected elements
sections.removeClass("active");
//add current selected element.
section.addClass("active");
}
Like this:
$('a[href^="#"]:not(#exception)').click(function (event) {
//do stuff
});
Fiddle: http://jsfiddle.net/KyleMuir/vD3vP/1/
EDIT: You can determine whether or not it is the exception like this:
//Smooth scroll when user click link that starts with #
$('a[href^="#"]').click(function (event) {
if (!$(this).is('#exception')) {
alert('Hi');
}
//prevent the browser from jumping down to section.
event.preventDefault();
});