0 like 0 dislike
16 views
asked in Programming by (5.6k points)

How I can to create HTML element on pure JavaScript?

js create html element

Your answer

Try to answer the question as detailed as possible.
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 (5.6k 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 20 views
0 like 0 dislike
1 answer 20 views
0 like 0 dislike
1 answer 16 views
0 like 0 dislike
1 answer 27 views
0 like 0 dislike
1 answer 25 views
0 like 0 dislike
1 answer 1 view
0 like 0 dislike
1 answer 15 views
0 like 0 dislike
1 answer 25 views
0 like 0 dislike
1 answer 28 views
asked Oct 10, 2018 in PHP by Pantycle_Genefanty (5.6k points)
...