onmouseover doesn't work when using javascript to add img tag on IE

前端 未结 4 687
闹比i
闹比i 2021-01-13 14:24

I need some javascript code that dynamically adds an img tag to a div, and the img tag needs onmouseover and onmouseout handlers.

I have it working on Firefox. But

4条回答
  •  不要未来只要你来
    2021-01-13 15:24

    Turns out IE doesn't support the addEventListener method. You can check a workaround here.

    Anyway, why don't you use jQuery? It almost overrides all the compatibility issues, has a handful of extras and it totally rocks.

提交回复
热议问题