jquery - 当页面宽度小于960px时,使用jquery更改<menu>高度

标签 jquery jquery-animate height width

当页面宽度小于960px时如何使用jquery改变元素的高度

这是我尝试过的:

$(document).ready(function() {

if ( $(window).width() < 960) {
    $('menu').animate({height:'60px'});
}
else {
    $('menu').animate({height:'40px'});
}

});

但它仅在刷新页面时才起作用,并且我希望在页面加载后重新调整页面大小时它才起作用。

最佳答案

 $('menu').animate({height:'60px'});
    ^^^^
 here is the error if menu is `id` than should be `#menu` if `class` than `.menu`

菜单标签浏览器支持

enter image description here

关于jquery - 当页面宽度小于960px时,使用jquery更改<menu>高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12549965/

相关文章:

jquery - 使用 css3 进行图像缩放和变换

html - 显示 : Table-cell with set width/cells on multiple lines

css - 最小高度 :100% do not apply height:100% 的 child

javascript - <form> 外部提交按钮中带有 "formnovalidate"的 jQuery 验证

javascript - 如何创建一个在鼠标悬停时显示更多信息的 div(带有背景图像?

javascript - 将鼠标悬停在图像顶部的图像 anchor 上时出现 jQuery 问题

html - 为什么当缩放改变时具有相同高度 "look"的元素不同?

javascript - Angular js : How to make make ajax call for directives to create options

jquery - 响应式裁剪图像,保持图像中心可见(水平)

在 div 内部时,jQuery 滚动无法正常工作