Home >Web Front-end >JS Tutorial >How to adapt getElementsByName to IE and firefox_javascript skills
In the w3c specification, getElementsByName is retrieved by the name attribute, but MS's IE is retrieved by the id. As a result, we cannot get the Elements we should get. To adapt to the browser, we can make some adjustments:
1. Add id to the names that need to use getElementsByName, and the id and name are the same.
2. Use a function to adapt to the browser. The code is as follows: