javascript - Inserting HTML text in js code -
how import html file in javascript code?
currently have like:
document.getelementbyid("menu").innerhtml = '<li class="topline"><a href="#">some text</a></li> <li><a href="#">some text </a></li> <li><a href="#">some text</a></li> <li><a href="#">some text</a></li> <li><a href="#"some text</a></li> <li><a href="#">some text</a></li> <li><a href="#">some text</a></li>';
how separate js code , html code in separate files. later load html code javascript easily?
you can this! taken below reference link!
you need put ul , li tags inside file called import.htm
, needs in same place current file.
var ajax = new xmlhttprequest(); ajax.open("get", "import.htm", false); ajax.send(); document.getelementbyid("menu").innerhtml += ajax.responsetext;
reference:
Comments
Post a Comment