これを試して:
$(function() {
jQuery(".gallery-item a").click(function(evt) {
jQuery("#imageBox").empty().append(
jQuery("<img />", { src: $(this).attr("href") })
);
return false;
});
});
コメント用に編集:
画像のURLが属性「data-urlimage」タグ「a」にあると仮定します
HTML:
<div class="gallery-item">
<a data-urlimage="/img/myimage.jpg" href="#">click here</a>
</div>
Javascript:
$(function() {
jQuery(".gallery-item a").click(function(evt) {
var img = new Image();
img.src = $(this).data("urlimage");
img.onload = function(){
jQuery("#imageBox").empty().append(img);
};
return false;
});
});
画像イベントを見る
編集:より良いオブジェクト「画像」を作成する方法を参照してください