Several jQuery selection criteria with Internet Explorer

I'm trying to select elements that match ".class#id" , which seems as natural as jquery multiple selectors, select elements that match both criteria ,

but it only works in firefox. IE just doesn't support it ?!

In particular, I have

 <div id="A" class="x"> <div id="A" class="y"> </div> </div> 

And I want to select $( ".y#A" )

Thanks Nick

+4
source share
2 answers

You should not have multiple elements with the same identifier. Internet Explorer will probably find out. (Or it doesn’t recognize it, but coincidentally has an error that behaves as if it were, and Microsoft decided to call it a function.)

Just specify elements that currently have the same identifiers, different identifiers, and a common class name. Then you can use $('.class.class2') and it will work in IE.

+6
source

IE will complain that you have two elements with the same identifier and cause some unusual actions.

+2
source

Source: https://habr.com/ru/post/1346052/


All Articles