jquery 手风琴获取高度值
jquery accordion get height value
我想获得活动时各个面板的高度值。我知道我可以使用 $(document).height()
或 $(window).height()
,但我想要活动面板的实际高度值。这可能吗?
<ul id="allTabs">
<li><a id="tab-1" href="#buildTab" onclick='windowResize("mainAccordion");' >Build</a></li>
<li><a id="tab-5" href="#setupTab" onclick='windowResize("setupAccordion");'>Setup</a></li>
</ul>
function windowResize(what){
var setupActive=$('#mainSetupAccordion').accordion('option', 'active').toString();
var mainActive=$('#accordion').accordion('option', 'active').toString();
if (what=='setupAccordion'){
var windowHeight=$('#mainSetupAccordion').outerHeight(true);
var buttons=0;
};
if (what=='mainAccordion'){var windowHeight=$('#accordion').outerHeight(true); var buttons=25};
if (setupActive=='false' && what=='setupAccordion'){windowHeight=104};
if (mainActive=='false' && what=='mainAccordion'){windowHeight=79};
var window_size=windowHeight+87+buttons;
$('#tab_sizes').val(window_size);
window.location='skp:resizeWindow';
};
基本上,我试图让 window 随手风琴一起动态调整大小,如果我留在选项卡内,它会起作用。如果我切换选项卡,我得到的结果是 0 而不是手风琴面板值。
你可以使用
$('#activePanel').outerHeight(true);
如果您有多个手风琴,请给出相同的 class 并使用 .each();
$('.Panels').each(function(){
var actualHeight = $(this).outerHeight(true);
console.log(actualHeight );
});
我找到了一种方法来完成这项工作,修改了功能...它可能不漂亮,但它确实有效。
function windowResize(what){
var setupActive=$('#mainSetupAccordion').accordion('option', 'active').toString();
var mainActive=$('#accordion').accordion('option', 'active').toString();
if (what=='setupAccordion'){
var windowHeight=$('#mainSetupAccordion').outerHeight(true);
var buttons=0;
if (setupActive=='false' && what=='setupAccordion'){windowHeight=104};
if (windowHeight!=0) {
setupAccordionPanel=[]
setupAccordionPanel.push(windowHeight)
}else{
windowHeight=setupAccordionPanel[0]
}
};
if (what=='mainAccordion'){
var windowHeight=$('#accordion').outerHeight(true);
var buttons=25
if (mainActive=='false' && what=='mainAccordion'){windowHeight=79};
if (windowHeight!=0) {
mainAccordionPanel=[]
mainAccordionPanel.push(windowHeight)
}else{
windowHeight=mainAccordionPanel[0]
}
};
var window_size=windowHeight+87+buttons;
$('#tab_sizes').val(window_size);
window.location='skp:resizeWindow';
};
我想获得活动时各个面板的高度值。我知道我可以使用 $(document).height()
或 $(window).height()
,但我想要活动面板的实际高度值。这可能吗?
<ul id="allTabs">
<li><a id="tab-1" href="#buildTab" onclick='windowResize("mainAccordion");' >Build</a></li>
<li><a id="tab-5" href="#setupTab" onclick='windowResize("setupAccordion");'>Setup</a></li>
</ul>
function windowResize(what){
var setupActive=$('#mainSetupAccordion').accordion('option', 'active').toString();
var mainActive=$('#accordion').accordion('option', 'active').toString();
if (what=='setupAccordion'){
var windowHeight=$('#mainSetupAccordion').outerHeight(true);
var buttons=0;
};
if (what=='mainAccordion'){var windowHeight=$('#accordion').outerHeight(true); var buttons=25};
if (setupActive=='false' && what=='setupAccordion'){windowHeight=104};
if (mainActive=='false' && what=='mainAccordion'){windowHeight=79};
var window_size=windowHeight+87+buttons;
$('#tab_sizes').val(window_size);
window.location='skp:resizeWindow';
};
基本上,我试图让 window 随手风琴一起动态调整大小,如果我留在选项卡内,它会起作用。如果我切换选项卡,我得到的结果是 0 而不是手风琴面板值。
你可以使用
$('#activePanel').outerHeight(true);
如果您有多个手风琴,请给出相同的 class 并使用 .each();
$('.Panels').each(function(){
var actualHeight = $(this).outerHeight(true);
console.log(actualHeight );
});
我找到了一种方法来完成这项工作,修改了功能...它可能不漂亮,但它确实有效。
function windowResize(what){
var setupActive=$('#mainSetupAccordion').accordion('option', 'active').toString();
var mainActive=$('#accordion').accordion('option', 'active').toString();
if (what=='setupAccordion'){
var windowHeight=$('#mainSetupAccordion').outerHeight(true);
var buttons=0;
if (setupActive=='false' && what=='setupAccordion'){windowHeight=104};
if (windowHeight!=0) {
setupAccordionPanel=[]
setupAccordionPanel.push(windowHeight)
}else{
windowHeight=setupAccordionPanel[0]
}
};
if (what=='mainAccordion'){
var windowHeight=$('#accordion').outerHeight(true);
var buttons=25
if (mainActive=='false' && what=='mainAccordion'){windowHeight=79};
if (windowHeight!=0) {
mainAccordionPanel=[]
mainAccordionPanel.push(windowHeight)
}else{
windowHeight=mainAccordionPanel[0]
}
};
var window_size=windowHeight+87+buttons;
$('#tab_sizes').val(window_size);
window.location='skp:resizeWindow';
};