Reputation: 7143
I have a jquery selector that I would like to change so that it wont select <div id="divA"></div>
.
Heres the current selector:
$('ul.toggle a').on('click', function () {
//does some work
});
I tried $('ul.toggle a [id!=divA]')
but that thows errors.
What is the intended format for this selector?
Upvotes: 0
Views: 374
Reputation: 148110
You can use :not to remove elements from the set of matched elements.
$("ul.toggle a:not('#mhs-link')")
Upvotes: 8
Reputation: 47956
How about this-
$('ul.toggle a').not('#divA')
The .not()
function simply removes elements from a previous list of elements. Because of some nifty function chaining, you can just insert that into your current definition -
$('ul.toggle a').not("#divA").on('click', function () {
//does some work
});
References
not()
- Remove elements from the set of matched elements.Upvotes: 5