그래서 저는 망막 그래픽을 적용하기 위해 jQuery 플러그인을 작성하고 있습니다. 요소 (배경 이미지 또는 소스 이미지가있는 경우)를 선택한 다음 내부에있는 모든 요소 (배경 이미지 또는 소스 이미지가있는 경우)를 선택해야합니다. 그들은 CSS background-image
속성이 경우 배경 이미지가있는 경우 신체 요소를 반환해야이미지가있는 부모 내의 모든 요소를 선택하십시오.
//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();
, 그들이 <img src="" />
경우 내의 모든 요소 나 :
여기 내 플러그인입니다.
어떻게하면됩니까?
UPDATE 오후 9시 13분 :
이 아무것도에 클래스 HAS_IMAGE를 추가하지 않고, 내가 || ($this.css('backgroundImage') !== 'none');
를 제거하는 경우가 여전히 <img>
요소를 선택하지 않습니다.
//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()
내 음모 이론가는 지난 며칠 동안 다운볼트 로봇이 있다고 의심하기 시작했습니다. 나는 이것이 왜 득표되지 않았는지 알지 못한다. –
누가 그것을 downvoted? 그것은 downvotes가 없습니다. – alt
아, 한참 전이었습니다. –