我正在尝试制作一个脚本,它将在一定分辨率以上完成相同的高度函数.
一旦低于该分辨率,我希望脚本关闭,因为相同高度的列在网站的移动版本上消失.
我希望这也可以在resize上执行.到目前为止,这是我的代码.这根本不起作用.
这是我的代码:
原始拉伸功能
$(document).ready(function () { var $stretch = $(".eq"); $stretch.animate({ height: $stretch.parent().height() },300 ); });
调整不起作用的功能
$(document).ready(function() { // Optimalisation: Store the references outside the event handler: var $window = $(window); var $stretch = $("#narrow") var $stretch2 = $(".eq") function checkWidth() { var windowsize = $window.width(); if (windowsize > 440) { //if the window is greater than 440px wide then turn on jScrollPane.. $stretch.animate({ height: $stretch.parent().height() },800 ); $stretch.animate({ height: $stretch2.parent().height() },300 ); } } // Execute on load checkWidth(); // Bind event listener $(window).resize(checkWidth); });
我怎样才能做到这一点?