jquery html() strips out script tags

前端 未结 5 971
再見小時候
再見小時候 2020-11-28 14:17

I need to replace the content of a div in my page with the html resultant from an ajax call. The problem is that the html have some necessary scripts in it and it seems that

5条回答
  •  悲&欢浪女
    2020-11-28 14:42

    This is the easiest solution:

    var keepScripts;
    keepScripts = true;
    $.parseHTML(yourHtmlString, keepScripts);
    

    This will keep the script tags in ;)

提交回复
热议问题