考虑以下代码:
$(".lcontainer a").click(function () {
var current = $(this);
var name = current.attr('href');
document.getElementsByName('source')[0].value = name;
var fPicture = "css/imgs/Flash.png";
//If image is wrapped in link unwrap it
var newLink = $('<a/>').attr('href', name);
newLink.find('#prev').unwrap();
if (extension == "jpg" || extension == "png" || extension == "gif" || extension == "bmp") {
$(".mainCategory").html("Picture");
document.getElementById('prev').src = name;
}
else if (extension == "swf") {
$(".mainCategory").html("Game");
document.getElementById('prev').src = fPicture;
previewImage.wrap(newLink);
}
return false;
});
});
逻辑很简单:如果我们有 swf 文件,则放入 flash 符号并用指向该文件的链接包装符号。问题:单击另一个链接,符号未解包。