1

How do I import a html file in to javascript code?

Currently I have to do something 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 do I separate the js code and html code in to separate files. Later load the html code into javascript easily?

Shyamal Parikh
  • 2,680
  • 3
  • 27
  • 66
  • This may help you: https://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file – xsami Sep 13 '17 at 18:44
  • 1
    You mean that you want to have that particular `
  • ...
  • ` code in a separate html file so you can get it to use? – Dejan.S Sep 13 '17 at 18:45
  • Possible duplicate of [Javascript import html is it possible?](https://stackoverflow.com/questions/4818854/javascript-import-html-is-it-possible) – Jino Shaji Sep 13 '17 at 18:47