Biggs
Biggs

Reputation: 27

Using multiple jquery selectors for href contains

I'm trying to prevent a specific div from displaying when any given url opens a new window/tab (which works), or when the url ends with .csv or .xlsx. When I add the .csv/.xlsx part to my selectors, the loading function is never reached. Any help is appreciated!

$(function () {
    $(document).on('click', "a[target!='_blank'], a[href$!='.csv'], a[href$!='.xlsx']", loading);
});

Upvotes: 0

Views: 938

Answers (1)

Rashmin Javiya
Rashmin Javiya

Reputation: 5222

You will have to use :not for the negation of the selector.

$(document).on('click', "a[target!='_blank'], a:not([href$='.csv']),a:not([href$='.xlsx'])", loading)

Upvotes: 2

Related Questions