Insert html using jquery .html()

前端 未结 7 706
面向向阳花
面向向阳花 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:05

    If it's coming in from a link, you'll probably want to do it with AJAX:

    $("#YOUR_ELEMENT").load("THE_CONTENT_TO_LOAD");
    

    However, keep in mind if you're trying to pull HTML from a site on a different domain you'll need to use server proxies and all that stuff...kind of out of the scope of the question.

提交回复
热议问题