Aryan PrajapatKnowledge Contributor
List the disadvantages of using innerHTML in javascript.
List the disadvantages of using innerHTML in javascript.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
The innerHTML property is a part of the DOM and is used to set or return the HTML content of an element. The return value represents the text content of the HTML element. It allows JavaScript code to make changes to a website being rendered.
The disadvantages of using innerHTML are:
1.Appending to innerHTML is not supported without reparsing the whole innerHTML.
2.As reparsing is required for innerHTML the processing is slow and takes more time.
3.The event handlers do not attach automatically to the newly created elements by setting innerHTML. One must keep track of the event handler and attach the new element manually.
4.By using innerHTML if you add, append, delete or modify contents on a webpage all contents are replaced, also all the DOM nodes inside that element are reparsed and recreated.
5.No proper validation is provided by innerHTML, hence any valid HTML code can be used. This may break the document of JavaScript.