Reputation: 8214
How do I change this selector to only call my function if the target does NOT have a specific class on it ('noscroll' as shown below)?
$('a[href^="#"]').live('click', navigation.smoothScroll);
<a class="noscroll" href="#">My Link</a>
Something like this (psuedo code):
if (!($this).hasClass('noscroll'))
($this).live('click', navigation.smoothScroll);
Upvotes: 1
Views: 165
Reputation: 86882
use the :not() selector
$('a[href^="#"]:not(.noscroll)').live('click', function () {
//your code here
});
Upvotes: 1
Reputation: 50493
You can use .not()
$('a[href^="#"]').not('.noscroll').live('click', navigation.smoothScroll);
Upvotes: 2