Insert html using jquery .html()

前端 未结 7 714
面向向阳花
面向向阳花 2021-02-08 15:58

I want to insert a large chunk of html into a pre-existing . I am using this method:

 $(\"td#content\").html(LOTS_OF_HTML_CODE_HERE);
         


        
7条回答
  •  醉酒成梦
    2021-02-08 16:02

    Javascript doesn't have good support for multi-line strings or HEREDOC syntax, but there are a few workarounds.

    Add a backslash "\" to the end of each line to let the script engine know you are continuing onto the next line without finishing:

    
    

    Use an XML CDATA hack(http://mook.wordpress.com/2005/10/30/multi-line-strings-in-javascript/):

    
    

提交回复
热议问题