Insertion d'éléments HTML avec JavaScript
function create(htmlStr) {
var frag = document.createDocumentFragment(),
temp = document.createElement('div');
temp.innerHTML = htmlStr;
while (temp.firstChild) {
frag.appendChild(temp.firstChild);
}
return frag;
}
var fragment = create('<div>Hello!</div><p>...</p>');
// Vous pouvez utiliser des méthodes DOM natives pour insérer le fragment:
document.body.insertBefore(fragment, document.body.childNodes[0]);
Also in HTML:
- how to add a rollover image in html
- theme color
- htmladjacent
- html template page
- how to use icon in html
- how to change font colour in html
- basic html template
- button open link in new tab
- add link behind a button in html
- tabs to other pages html
- current date in html5
- favicon html link
- what does html stand for
- html ecrire en gras
- pass dynamic javascript value to html
- Insertion d'éléments HTML avec JavaScript
- how to increase font size in html
- jupyter notebook download as html without code
- unordered list html
- import js in html
- djnago
- how to do animation with pure javascript with no html
- favicon in html
- vue class binding