window.onload = function() { var text = document.getElementById("text"); document.getElementById('btn').onclick = function () { var xmlHttp; if (window.XMLHttpRequest) xmlHttp = new XMLHttpRequest(); else xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.onreadystatechange = function () { if (xmlHttp.status == 200 && xmlHttp.readyState == 4) { var htmlStr = xmlHttp.responseText;//获取的是一string var node = strToNode(htmlStr);//获取到想要的html元素