jrq*_*ick 13 html javascript css
假设我有一个页面,a.html并希望使用<p id="name">NAME</p>来自另一个页面的id 元素来检索文本元素的文本b.html.
xan*_*ded 19
使用jQuery的get方法,它非常简单:
$.get('a.html', null, function(text){
alert($(text).find('#name'));
});
Run Code Online (Sandbox Code Playgroud)
原始XHR请求(按流行需求):
var request = new XMLHttpRequest();
request.addEventListener("load", function(evt){
console.log(evt);
}, false);
request.open('GET', 'a.html', true),
request.send();
Run Code Online (Sandbox Code Playgroud)