Created
October 21, 2013 08:05
-
-
Save jswhisperer/7080224 to your computer and use it in GitHub Desktop.
insertAdjacentHTML javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var box2 = document.getElementById("box2"); | |
| box2.insertAdjacentHTML('beforebegin', '<div><p>This gets inserted.</p></div>'); | |
| //beforebegin | |
| //The HTML would be placed immediately before the element, as a sibling. | |
| //afterbegin | |
| //The HTML would be placed inside the element, before its first child. | |
| //beforeend | |
| //The HTML would be placed inside the element, after its last child. | |
| //afterend | |
| //The HTML would be placed immediately after the element, as a sibling. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment