Javascript 浏览器没有';t呈现表元素| jsFiddle示例
我的代码使用James Padolsey的“jQuery的跨域mod”跨域请求获取网页源代码: 然后选择第一个表并将其附加到现有div 但是附加的表没有得到正确的呈现。谁能看看这把小提琴,告诉我为什么Javascript 浏览器没有';t呈现表元素| jsFiddle示例,javascript,jquery,Javascript,Jquery,我的代码使用James Padolsey的“jQuery的跨域mod”跨域请求获取网页源代码: 然后选择第一个表并将其附加到现有div 但是附加的表没有得到正确的呈现。谁能看看这把小提琴,告诉我为什么 您正在使用jQuery。。因此,您可以通过将其转换为jQuery对象来遍历它 function stripViewResponse() { // Select table element var fetchedTable = $(antwort).find('table')[0]; // fi
您正在使用jQuery。。因此,您可以通过将其转换为jQuery对象来遍历它
function stripViewResponse() {
// Select table element
var fetchedTable = $(antwort).find('table')[0]; // find first table
// append table
$('#new').append(fetchedTable);
}
您也可以试试这个
function stripViewResponse() {
// Select table element
var fetchedTable = $(antwort).find('table').eq(0);
// append table
$('#new').append(fetchedTable);
}
令人惊叹的!正如你所看到的,我才刚刚开始。非常感谢。请注意,不要使用全局变量将响应从一个函数传递到另一个函数。将其作为参数传递:
stripViewResponse(res.responseText)
并将其作为参数接收函数stripViewResponse(antwort){…
我知道。但是你是对的,其他人可能不会。因此感谢你的提示。这是更新的JSFIDLE:谢谢!它几乎与@wirey建议的相同。