I am using jQuery to capture all the links which have a class “current” in a way.
Here is my code:
$('#filter-by li ul a').live('click',function(e){
var terms_ids = '';
var taxonomies = '';
$('#filter-by li ul a.current').each( function() {
terms_ids = terms_ids + $(this).parent().attr('class').replace(/[^0-9]/g, '') + ',';
taxonomies = taxonomies + $(this).closest('.tax-parent-li').find('ul li:first a').attr('rel').replace(/default_/, '') + ',';
});
});
When the link is clicked, I wanted it to calculate/capture all elements which have the class current, I used each loop for this. But I want to make an exclusion and not sure how to do it, I do not want it to take into account the current clicked link if the current clicked link already has *.current class.*
There are multiple links with current class, I want to avoid the one being clicked if it already has current class previously.
I appreciate any help on this.
I can’t tell exactly what’s required without more markup and information, but you may find
.not()useful.For example,
will call the
.eachcallback on every element matching the selector except for the current element (i.e.this).