您好我的应用程序中我想尝试从其他页面获取一些HTML内容
var city_name = encodeURIComponent(self.banners()[self.currentIndex].city.name);
var url = "http://www.example.com/banners?city=" + city_name;
var req = new XMLHttpRequest();
req.open('GET', url, false);
req.send(null);
var text = req.response;
在输出中我有一些html
<html>
<body>
<div>
TEXT
</div>
</body>
</html>
如何从输出html&#39; div中获取内容?
谢谢!
答案 0 :(得分:1)
试试这个:
text.getElementsByTagName('div')[0].textContent;