简体   繁体   中英

querySelectorAll ":not" doesn't work in IE8, does jQuery's version?

Unfortunately I have to support IE8 and need to select inputs using the :not modifier. I know that IE8 doesn't support this in querySelectorAll but does jQuery's version support IE8 for this?

querySelectorAll:

domElement.querySelectorAll( "input:not([name*='[statistic]']):not([type=button]),textarea:not([name*='[statistic]'])" );

jQuery:

jQuery( "input:not([name*='[statistic]']):not([type=button]),textarea:not([name*='[statistic]'])", domElement );

Short answer: Yes.

One of the main things that made jQuery popular in the first place was that it allowed older browsers to support the new selectors like :not .

So yes, you will be able to use :not and other selectors in jQuery code.

You can't use :not with querySelectorAll() in IE8 because IE8 simply doesn't support it. IE8 supports CSS2.1 which was the current standard at the time it was released. :not simply wasn't in the picture. And you can't use querySelectorAll() at all in older IE versions than that.

jQuery was created specifically to deal with these issues and allow developers to support older IE versions while still allowing us to use modern browser features.

There may be people today saying that you don't need jQuery any more, but if you need to support old IE versions, the need for jQuery is just as much as it always was.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM