【问题标题】:How to get the element height correctly with jquery如何使用 jquery 正确获取元素高度
【发布时间】:2015-12-21 20:55:52
【问题描述】:

我有一个带有元素的 Bxslider,我需要以某种方式触发一个 lelemt 高度,并根据该高度为该元素提供一些其他填充。这是我的代码无法正常工作

jQuery('.servicesmobilecatswrap').bxSlider({
    mode: 'fade',
    pager :false,
    adaptiveHeight: true,
    nextSelector: '#servicecat_next',
    touchEnabled : false,
    onSliderLoad : function () {  
        var windowWidth = jQuery(window).width();
        if(windowWidth < 480){
            jQuery('.servicesmobiletitle').each(function(){
                if(jQuery(this).outerHeight() < 85){
                    //alert('yes');
                    jQuery(this).css({'padding-top':'62px'});
                }
            });
        }
    },
    onSlideBefore : function () {  
        var windowWidth = jQuery(window).width();
        if(windowWidth < 480){
            jQuery('.servicesmobiletitle').each(function(){
                if(jQuery(this).outerHeight() < 85){
                    //alert('yes');
                    jQuery(this).css({'padding-top':'62px'});
                }
            });
        }
    }, 
    onSlideAfter : function () {  
        var windowWidth = jQuery(window).width();
        if(windowWidth < 480){
            jQuery('.servicesmobiletitle').each(function(){
                if(jQuery(this).outerHeight() < 85){
                    //alert('yes');
                    jQuery(this).css({'padding-top':'62px'});
                }
            });
        }
    },
prevSelector: '#servicecat_prev', 
nextText: '',
prevText: '' 
});

这里是 HTML

<div class="servicemobilecatitem">
         <div class="servicesmobiletitle">Branding</div>
          <div class="servicesmobiletext">hghfghfgh</div>
</div>

【问题讨论】:

标签: jquery height bxslider


【解决方案1】:

我在你的网站上检查了这个,发现“这个”有它的对象,

【讨论】:

  • 我也无法理解为什么它不能正常工作,如果你看一下你会发现填充适用于所有标题项目,所以如果不工作
猜你喜欢
  • 2017-01-21
  • 2010-11-20
  • 1970-01-01
  • 2014-09-14
  • 2011-08-05
  • 2013-12-28
  • 1970-01-01
  • 2012-05-01
  • 2015-02-20
相关资源
最近更新 更多