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:

  1. javascript import html

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -