Home >
Web Front-end >
JS Tutorial >
Solution to the problem that the name attribute cannot be set when creating input using javascript createElement()_javascript skills
Solution to the problem that the name attribute cannot be set when creating input using javascript createElement()_javascript skills
WBOY
Release: 2016-05-16 18:45:00
Original
1395 people have browsed it
Among them, obj.name = "select"; does not have the expected effect. Whether you look at the generated HTML code or observe the length of the array obtained using document.getElementsByName(), you will find that this name setting does not work. . Of course, this situation only occurs in IE6 and IE7, but there is no problem in FireFox.
Of course the solution is very simple, When creating, use document.createElement(""). But I still don’t know the reason? There is this sentence in the description of the Name attribute: In Internet Explorer 5, the name property cannot be set at run time on anchor objects dynamically created with the createElement method. To create an anchor with a NAME attribute, include the attribute and value when using the createElement method, or use the innerHTML property.
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