0 like 0 dislike
8 views
asked in Programming by (4.7k points)

How I can to create HTML element on pure JavaScript?

js create html element

Your answer

pre, code

Preview

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

0 like 0 dislike
answered by (4.7k points)

Like this:

var el = document.createElement('p');
var elTxt = document.createTextNode('foo');
el.appendChild(elTxt);
var parent = document.getElementById('parentEl');
parent.insertAdjacentElement('afterend', el);

Related questions

0 like 0 dislike
1 answer 9 views
0 like 0 dislike
1 answer 10 views
0 like 0 dislike
1 answer 10 views
0 like 0 dislike
1 answer 13 views
0 like 0 dislike
1 answer 21 views
0 like 0 dislike
1 answer 11 views
0 like 0 dislike
1 answer 16 views
0 like 0 dislike
1 answer 16 views
asked Oct 10, 2018 in PHP by Pantycle_Genefanty (4.7k points)
0 like 0 dislike
1 answer 8 views
...