-1
我碰到這個片段,其功能是用跨度包裹img標籤並製作跨度的圖像背景圖像。我的問題是,我如何才能使它只適用於特定的img標籤或某些div中的某些img標籤?如何使jquery片段僅適用於某些特定的標籤?
$(文件)。就緒(函數(){
$("img").load(function() {
$(this).wrap(function(){
return '<span class="image-wrap ' + $(this).attr('class') + '"
style="position:relative; display:inline-block; background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />';
});
$(this).css("opacity","0");
});
});