Yes, when you do:
document.body.innerHTML += '<br>';
You’re really doing:
document.body.innerHTML = (document.body.innerHTML + '<br>');
So you’re completely destroying and recreating all the content.
More Related Contents:
- How can I tell if a DOM element is visible in the current viewport?
- How to make JavaScript execute after page load?
- JavaScript, browsers, window close – send an AJAX request or run a script on window closing
- Appending HTML string to the DOM
- Firing event on DOM attribute change
- How to get a word under cursor using JavaScript?
- Event when window.location.href changes
- Why is the DOMSubtreeModified event deprecated in DOM level 3?
- How do I programmatically click on an element in JavaScript?
- Browser event when downloaded file is saved to disk
- Pass mouse events through absolutely-positioned element
- Using this inside an event handler
- How to know whether refresh button or browser back button is clicked in Firefox [duplicate]
- Detecting if a browser is in full screen mode
- ES6 Class: access to ‘this’ with ‘addEventListener’ applied on method [duplicate]
- Native JS equivalent to jQuery delegation
- Are event handlers in JavaScript called in order?
- HTML DOM: Which events do not bubble?
- Do I need to remove event listeners before removing elements?
- link element onload
- Is it possible to programmatically catch all events on the page in the browser?
- event.toElement in IE8 and Firefox?
- cloning javascript event object
- How can I know whether refresh button or browser back button is clicked in Firefox? [duplicate]
- Is it possible to catch browser’s File Open/Save dialog event using Javascript
- Getting the text from a drop-down box
- How browser executes Javascript and renders asynchronously
- In web browsers, what’s the difference between onblur and onfocusout?
- Replacement for deprecated `keypress` DOM event
- Manually dispatchEvent DOMContentLoaded