我正在尝试为特定选项卡激活时执行脚本,我的代码就像这样。每个标签都有不同的尺寸,我希望.content
将在每个标签上更改其高度。
<div class="content">
<ul>
<li><a href="#1">1</a></li>
<li><a href="#2">2</a></li>
<li><a href="#3">3</a></li>
<li><a href="#4">4</a></li>
</ul>
<div id="1" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> ... </div>
<div id="2" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> ... </div>
<div id="3" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> ... </div>
<div id="4" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> ... </div>
</div>
这是.leftup的css
.leftupt {
display: block;
font-family: 'FuturaLTRegular';
height: auto;
left: 31px;
margin: 0 !important;
padding: 0;
position: absolute;
text-align: center;
top: 429px;
width: 360px !important;
}
现在这就是它的样子..
<div id="1" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> ... <script></script> </div>
<div id="2" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> ... <script></script> </div>
<div id="3" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> ... <script></script> </div>
<div id="4" class=".singles"><div class="leftupt">...</div><div class="wrapright"> ...</div> <script></script> </div>
我的脚本是这样的,但它不会工作......
<script type='text/javascript'>
var biggestHeight = jQuery(".content").height();
jQuery(".leftupt").each(function(){
if (jQuery(this).height() > biggestHeight ) {
biggestHeight = jQuery(this).height();
}
});
if (jQuery('.leftupt').height == 0){
biggestHeight=jQuery('.content').height();
}
jQuery(".content").height(biggestHeight);
</script>
它是否有可能使.content
高度是动态的而不是静态的,如果.left的高度是什么,它还是.content的长度?
答案 0 :(得分:0)
尝试更改此
if (jQuery('.leftupt').height == 0)
到
if (jQuery('.leftupt').height() == 0)