2013-07-01 19 views

cevap

3
// jQuery no conflict mode 
var j = $.noConflict(); 

// retain meaning of jQuery's handle (optional but makes it 
// sometimes easier if you don't use one-letter assignments 
// of jQuery) 
(function($){ 

    // document read 
    $(function(){ 
    // if element is visible (a visible #element was found) 
    if $('#element:visible').size() > 0){ 
     // scroll to #target 
     $('body').scrollTo('#target'); 
    } 
    }); 

})(j); 

:visible kolaylaştırır. Sadece display=='block''a karşı test edemezsiniz, ayrıca inline-block ve diğerlerini de visibility ayarını kontrol etmek için test etmeniz gerekir. Örneğin, öğe display:block:visibility:hidden olabilir, bu da :visible yapamaz.

1

Kullanım .is() ve

var j = jQuery.noConflict(); 

jQuery(function($) { 
    if($('#element').is(':visible')){ 
     $('body').scrollTo('#target'); 
    }; 
}); 
İlgili konular