我正在尝试获取一个链接,单击该链接会将图像加载到 DIV 中。这是我到目前为止所拥有的:
http://jsfiddle.net/AndyMP/kgvux/
jQuery
$(function () {
$(".link").click(function (e) {
var url = $(this).data('href')
$('.enclosure').load(url)
return false;
});
});
HTML
.enclosure {
width: 400px;
height: 200px;
border: 1px solid black;
overflow: hidden;
}
.link {
cursor: pointer;
}
HTML
<div class="enclosure">
<img src="http://news.bbcimg.co.uk/media/images/67419000/jpg/_67419697_hull-getty.jpg">
</div>
<div class="link" data-href="http://news.bbcimg.co.uk/media/images/67424000/jpg/_67424686_67424685.jpg">Click me</div>