What is the difference between innerhtml and append() in javascript?



What is the difference between innerhtml and append() in javascript?..

Answer / Zia Khan Lohani

innerHTML sets the entire content of an element, replacing existing children. append() adds content to the end of an existing element without disturbing other siblings. For example: document.getElementById("myDiv").innerHTML = "newContent"; replaces everything inside myDiv, while document.getElementById("myDiv").append("newContent"); adds newContent at the end.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More JavaScript Interview Questions

Explain the typeof operator?

1 Answers  


What is a module code?

1 Answers  


what is the difference between wrappers and primitives es: diff between int i=200 in primitives and integeri = new integer(54)

1 Answers  


Which built-in method returns the calling string value converted to upper case?

1 Answers  


How to force a page to go to another page using javascript ?

1 Answers  


How to create the namespace in javascript?

1 Answers  


how to hide alphabets in java as password '*'

1 Answers  


How to create an object in javascript?

1 Answers  


How do I add javascript to chrome?

1 Answers  


What is an ECMAScript?

1 Answers  


How about 2+5+"8"?

6 Answers   Satyam,


How to open a window with no toolbar, but with the location object?

1 Answers  


Categories