javascript - 如何一个接一个地运行一个脚本?

标签 javascript jquery html css

我有一个浏览器调整脚本:

$(document).ready(function() {
    $(window).on('resize', function() {
        if ($(this).height() <= 800) {
            $('.content').css('max-height', '500px'); //set max height
        } 
        else {
            $('.content').css('max-height', ''); //delete attribute
        }
    }).resize()
})

我想让 jscrollpane 在窗口调整大小后运行,因为那时我需要滚动条。在我目前的代码中,它只显示常规滚动条。

$(function() {
    $('.scroll-pane').jScrollPane();
});

有没有办法在最大高度脚本完成后运行这个脚本?

最佳答案

<script type="text/javascript">
$(document).ready(function() {

   $(window).on('resize', function(){
     if ($(this).height() <= 800){
      $('.content').css('max-height', '500px'); //set max height
     } else{
      $('.content').css('max-height', ''); //delete attribute
   }

   $('.scroll-pane').jScrollPane(); //why not call it here?

 }).resize()
})
</script>

关于javascript - 如何一个接一个地运行一个脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11996183/

相关文章:

javascript - 正则表达式返回前两个整数

html - 在网页上使用直接 ASCII 字体有什么问题吗?

javascript - 通过 FireFox 在 html 中打印带有图表的表格

javascript - 如何在不点击或提交的情况下实时更新数据

jquery - 缩放视频时保持图像位置

javascript - 如何在 Meteor 中验证服务器上的用户创建

javascript - 将两个数组组合成选项数组

javascript - html表格项中的搜索过滤器[表格数组是异构的]

javascript - 链接到 iframe 外部

javascript - jQuery UI 日期选择器 : how to set container's display to flex?