简体   繁体   中英

IE js error with event.target !==

I have the following js code:

if ( event.target !== self.element[ 0 ]){
  ...
 } 

In IE browser I get this error: Object doesn't support this property or method

when I write my code :

if ( event.target == self.element[ 0 ]){
  ...
 } 

I don't get a js problem

what is not supported by IE? the !==?!!

Well there's no "target" property in IE; it's event.srcElement . So try

if ((event.target || event.srcElement) !== self.element[0]) 

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