Creating a
with javascript createElement?

后端 未结 5 740
终归单人心
终归单人心 2020-12-30 19:41

I need to create a
tag dynamically with javascript.

var br = document.createElement(\'br\');

And

         


        
5条回答
  •  别那么骄傲
    2020-12-30 19:58

    The first option will work and has nothing to do with XHTML since the DOM operations are performed after parsing of the document, and therefore there is no XHTML/HTML standard to be compliant to at that point. As long as you are not trying to output the HTML to a string, this approach will work just fine.

提交回复
热议问题