Home >Web Front-end >JS Tutorial >Get the code for the text of the option selected in the following box under firefox_javascript skills

Get the code for the text of the option selected in the following box under firefox_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:24:261015browse

Knowledge points:
0. Why innerText? Because of security issues
1. Extend attributes for the firefox dom model
2. The currentStyle attribute can obtain the actual style status
3. When IE implements innerText, it considers the display method. If it is a block, a newline is added
4. Why not use textContent? Because textContent does not take into account the display mode of the element, it is not fully compatible with IE.
Code: The test passed under IE6, 7, 8 and Firefox 2, 3.


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

Of course, if you target the drop-down alone box, you don’t need to rewrite innerText, you can also use the following code to achieve it. InnerText is rewritten to be compatible with other HTML elements except drop-down boxes.

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute ]
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