Home >Web Front-end >JS Tutorial >javascript Move the mouse to get the rowIndex position in the table where the cell is located [Compatible with ie, firefox] [Original]_javascript skills

javascript Move the mouse to get the rowIndex position in the table where the cell is located [Compatible with ie, firefox] [Original]_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:38:511269browse

The code I saw from cnblogs, the author’s code may not be compatible with Firefox, but it will help you learn why the following code is compatible with Firefox. You can compare it and it will help you learn. For more articles, you can refer to the script. Articles previously published by Zhijia.


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute it
]

The following code is part of the script Firefox-compatible code modified by home

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]
The main differences are as follows:
1. Event e.srcElement and e.target


People often ask how to use event.srcElement under firefox. Here is a detailed explanation:
Under IE, the event object has srcElement attribute, but there is no target attribute; under Firefox, the event object has the target attribute, but no srcElement attribute. But their functions are equivalent, that is:
event.target under firefox = event.srcElement under IE

Solution: Use obj (obj = event.srcElement ? event.srcElement : event.target;) instead of event.srcElement under IE or event.target under Firefox.
2 The difference between .parentNode and parentElement When using parentElement, it is invalid in FF. After searching, I found out that parentElement is exclusive to IE. IE’s dominance for many years has caused many applications to be incompatible with other browsers. , standardization is really important, haha, we must follow the Web standards
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn