gpt4 book ai didi

javascript - 有人可以告诉我为什么这个 js 函数不能在加载时运行吗?

转载 作者:行者123 更新时间:2023-11-28 11:36:32 27 4
gpt4 key购买 nike

我已经:

 //Resize tabs - height when window size changes. Don't forget to reset niceScroll
function recalc_tab_height () {
//
var wrapper_h = $(".ui-panel-content-wrap").outerHeight();
var content_h = $(".ui-content").outerHeight();
var current_h = $(".tab1").outerHeight();
var newHeight = (wrapper_h - content_h) + current_h;
//
$(".tab1, .tab2, .tab3").css({"height":newHeight}).getNiceScroll().resize();
}
//Run once onLoad
recalc_tab_height();

这应该在加载时调整歌词部分的大小以适合屏幕。但它根本不运行...有什么想法吗?它位于 ui.js 内部

http://mac.idev.ge:800/mobile-radio/

最佳答案

尝试

$(function() {
recalc_tab_height();
});

而不是最后一行。

$(...)$(document).ready(...) 的快捷方式,在页面完全加载后立即执行,这样您就可以处理 DOM 元素属性。

关于javascript - 有人可以告诉我为什么这个 js 函数不能在加载时运行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18631060/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com