Reputation: 171
I have a page with internal anchor tags that take the visitor to various div's on the page as well as jQuery tabbed content that also uses anchor tags. I am using ScrollMagic for smooth navigation between internal anchor tags but it also triggers on the jQuery tabbed content causing unwanted results. Is there a way to ignore certain internal anchor tags?
Here is the line of code that links ScrollMagic to internal anchor tags. How can I make it ignore a div with a certain class?
$('a[href*=#]:not([href=#])').click(function() {
Upvotes: 1
Views: 50
Reputation: 20633
Add the class to the :not
selector:
$('a[href*="#"]:not(.myclass, [href="#"])').on('click', function(e) {
e.preventDefault();
alert('click');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#">
triggers
</a>
<br>
<a href="#" class="myclass">
doesn't trigger
</a>
Upvotes: 2