Reputation: 5670
My code is like this
$("a[href]").each(function () {
if ($(this).attr("href").toLowerCase().indexOf("javascript:") != 0 && $(this).attr("class") != "to-top")
{
$(this).attr("href", new URI($(this).attr("href")).removeQuery("at").addQuery("at", $.cookies.get('ACCT_TYPE') != null ? $.cookies.get('ACCT_TYPE') : "erhverv"));
}
});
now i want to avoid a specific link from this condition ."a" links comes 'under tax-switch' class. is there any short cuts to achieve this?
Upvotes: 2
Views: 2289
Reputation: 14862
As @vivek has said, use the not
function:
$('a[href]').not('.tax-switch').each(
This'll select all anchors that do not have the class 'tax-switch'.
Upvotes: 4
Reputation: 10896
try this code , Working fiddle
$("a[href]:not(.tax-switch)").each(function () {
$("#myDIV").append('<p>'+ $(this).html()+'</p>');
});
Upvotes: 3
Reputation: 253318
Use filter()
:
$('a[href]').filter(function(){
return !$(this).hasClass('tax-switch');
}).each(function(){
// do your stuff
});
References:
filter()
.Upvotes: 0
Reputation: 24150
You can user jquery not selector. http://api.jquery.com/not-selector/
Upvotes: 1