how can I insert some HTML code between
using javascript?
Ex:
A simple way to do this with vanilla JavaScript would be to use appendChild
.
var mydiv = document.getElementById("mydiv");
var mycontent = document.createElement("p");
mycontent.appendChild(document.createTextNode("This is a paragraph"));
mydiv.appendChild(mycontent);
Or you can use innerHTML
as others have mentioned.
Or if you would like to use jQuery, the above example could be written as:
$("#mydiv").append("This is a paragraph
");