+ 1
Js alternatives?
Is there a pure JavaScript alternative to .append() in jQuery? This is for my code https://code.sololearn.com/Wp3feOX200z6/?ref=app
2 Answers
+ 1
jQuery:
$( "#blk" ).append( "<p>Text</p>" );
JavaScript alternative way:
var pElement = document.createElement("p");
var textNode = document.createTextNode("Text");
pElement.appendChild(textNode);
document.getElementById("blk").appendChild(pElement);
+ 1
Something like this?
https://www.w3schools.com/jsref/met_node_appendchild.asp