Can i manipulate an external HTML document with JQuery?

前端 未结 2 1431
隐瞒了意图╮
隐瞒了意图╮ 2021-01-29 04:57

I would like to sanitize a HTML document (created in google docs) so I can publish it on my CMS.

I have the source document in a string, from to , with header, style, b

相关标签:
2条回答
  • 2021-01-29 05:45

    I believe you can do what you're trying to do, but you're wording it improperly. You can grab the HTML from another document and manipulate it, but you can't manipulate the external document persay. You can grab it using

    $.get("url", function() {
      //modify stuff here
    });
    
    0 讨论(0)
  • 2021-01-29 05:48

    Try like this:

    var gdoc = '<html><body><div id="foo">Bar</div></body></html>';
    var data = $('<div/>').html(gdoc).find('#foo').html();
    alert(data);
    

    Demo.

    0 讨论(0)
提交回复
热议问题