サポート » 使い方全般 » jQueryでの高さ取得の件で

  • 解決済 osat99

    (@osat99)


    外部jsで以下コードを読み込みさせているのですが、
    高さ取得の箇所で、
    .swiper-containerから#mastheadを差し引いた高さを取得としたいのですが、
    heroBottom = jQuery(‘.swiper-container’).height(); の箇所をどのように書き換えすればよろしいでしょうか?

    よろしく回答のほどお願いいたします。

    jQuery(function(){
        var _window = jQuery(window),
            _header = jQuery('#masthead'),
            heroBottom;
    
        _window.on('scroll',function(){
            heroBottom = jQuery('.swiper-container').height();
            if(_window.scrollTop() > heroBottom){
                _header.addClass('transform');   
            }
            else{
                _header.removeClass('transform');   
            }
        });
    
        _window.trigger('scroll');    
    });
1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック投稿者 osat99

    (@osat99)

    以下コードで自己解決いたしました。
    ありがとうございました。

    jQuery(function(){
    	var _window = jQuery(window),
    		_header = jQuery('#masthead'),
    		heroBottom;
    	
    	_window.on('scroll',function(){
    		heroBottom = jQuery('.swiper-container').height();
    		herotop = jQuery('#masthead').height();
    		if(_window.scrollTop() > heroBottom-herotop){
    			_header.addClass('transform');   
    		}
    		else{
    			_header.removeClass('transform');   
    		}
    	});
    	
    	_window.trigger('scroll');	
    });
1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「jQueryでの高さ取得の件で」には新たに返信することはできません。