在下面的代码片段中,从我的jQuery安装程序中,我需要检查图像文件是否真的存在,如果没有,我想替换默认图像。目前,如果该文件不存在,我只是得到一个破碎的图像占位符...jQuery等价于PHP的file_exists()?
$('#myTheme').change
(
function()
{
var myImage = $('#myTheme :selected').text();
$('.selectedImage img').attr('src','../wp-content/themes/myTheme/styles/'+myImage+'/screenshot.jpg');
//if screenshot.jpg does not exist, use "../../default.jpg" instead
}
);