How to insert a large block of HTML in JavaScript?

后端 未结 7 844
悲哀的现实
悲哀的现实 2020-12-07 18:50

If I have a block of HTML with many tags, how do insert it in JavaScript?

var div = document.createElement(\'div\');
div.setAttribute(\'class\', \'post block         


        
7条回答
  •  一生所求
    2020-12-07 19:15

    If you are using on the same domain then you can create a seperate HTML file and then import this using the code from this answer by @Stano :

    https://stackoverflow.com/a/34579496/2468603

提交回复
热议问题