【发布时间】:2012-01-11 11:39:06
【问题描述】:
我正在尝试获取 .get 请求返回的特定 div 的 HTML(.get 请求返回具有 3 个具有 3 个不同 id 的 div 的 HTML 数据)
这是我的代码:
$.get("ajax/learn-more.html", function(data){
var $response = $(data);
alert($response.find('#main-images')); // <= prints [Object object]
alert("Data Loaded: " + data); // <= displaysthe whole html of learn-more.html
// how can I get the html of a div in learn-more.html with id="main-images" ???
});
编辑:
learn-more.html的内容:
<div id="something" class="hero-unit span-one-third" style="position: relative;">
Foo Bar
</div>
<div id="main-images" class="hero-unit span-one-third" style="position: relative;">
<div id="learn-more-photo" class="span-one-third">
<img class="thumbnail" src="http://placehold.it/300x180" alt="">
</div>
</div>
<div id="learn-more">
:D
</div>
【问题讨论】:
-
您的意思是像 in、to a printer 还是 to alert() 到屏幕上打印?
标签: javascript jquery ajax get