Home >Web Front-end >JS Tutorial >Analysis of disadvantages of dynamically modifying the id attribute in DOM_javascript skills
In IE, modifying the id attribute has no non-standard impact on future DOM operations. You can still find the element through document.getElementById(), but there will be problems with CSS support. The id will not be automatically removed after modification. Re-match CSS rules, so the id will not reflect the proper style after modification.
Therefore, you should avoid modifying the id attribute when doing DOM programming. If you need to dynamically change the matching CSS rules, change the class attribute. When I encountered this problem, I tried to modify the only element that matched a certain CSS filter by modifying the id attribute. It turned out that there was no modification at all in IE after the modification, and then I changed to the class attribute to achieve the same purpose.