だから私は網膜グラフィックスを適用するためのjQueryプラグインを書いています。要素(背景画像またはソース画像がある場合)を選択してから、その中のすべての要素(背景画像またはソース画像がある場合)を選択する必要があります。
これが私のプラグインです:
//RetinizeJS
(function($){
$.fn.retinize = function(){
$(this).filter(function(){
if (this.currentStyle)
return this.currentStyle['backgroundImage'] !== 'none';
else if (window.getComputedStyle)
return document.defaultView.getComputedStyle(this,null)
.getPropertyValue('background-image') !== 'none';
}).addClass('bg_found');
};
})(jQuery);
$('body').retinize();
背景画像がある場合はbody要素を返す必要があり、背景画像がある場合、<img src="" />
またはCSSbackground-image
プロパティがある場合はその中のすべての要素を返す必要があります。
どうすればこれを達成できますか?
更新9:13PM:
これはクラスHAS_IMAGEを何にも追加せず、<img>
削除しても要素を選択しません|| ($this.css('backgroundImage') !== 'none');
。
//RetinizeJS
(function($){
$.fn.retinize = function(){
$this = $(this);
$this.find('*').andSelf().filter(function(){
return $this.is('img') || ($this.css('backgroundImage') !== 'none');
}).addClass('HAS_IMAGE');
};
})(jQuery);
$('body').retinize()