jQuery.replaceWith doesn't take [removed] tags

前端 未结 3 572
渐次进展
渐次进展 2021-01-13 15:34

I have an AJAX response that contains some HTML, including

相关标签:
3条回答
  • 2021-01-13 16:24

    See jQuery.parseHTML( data [, context ] [, keepScripts ] )

    The following should work

    var content = jQuery.parseHTML(response, document, true)
    $(element).replaceWith(content)
    
    0 讨论(0)
  • 2021-01-13 16:25

    This code is from facebook's sample app. Insert <div id="fb-root"></div> in your document. The code requires jQuery to load up the script. In your case, replace //connect...../all.js' with the <script> elements.

    (function() {
    var e = document.createElement('script');
    e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
    }());
    
    0 讨论(0)
  • 2021-01-13 16:30

    It will return a string!!

    $.get("ajax.php")
         .success(function(returningHtmlString) {
              $(element).replaceWith(returningHtmlString);
         });
    
    0 讨论(0)
提交回复
热议问题