Can i manipulate an external HTML document with JQuery?

倖福魔咒の 提交于 2019-12-02 11:16:08

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.

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
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!