我在页面上有一些缩略图。当我点击其中的一个时,我想在Jquery对话框中查看原始照片。而且,我想根据照片宽度动态设置对话框的宽度。所以,我写了下面的脚本来完成它。但是,它看起来像我不能访问新添加到div的图像。以下是我写的功能:如何在使用jquery追加元素后调用函数?
function showOrignalPhoto($photo_name){
$('#image_frame img').remove(); //remove the previous image
$('#image_frame').append('<img src="../IMAGE_PATH/'+$photo_name +'" />'); //append new image
$width = $('#image_frame img').width(); //get width of the new image
alert($width); //return 0!!
$("#dialog").dialog("option", "width", $width); //set the width of the dialog box
$("#dialog").dialog("open"); //open the dialog
}
非常感谢。 – Newbie