Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 更改浏览器宽度上的li高度调整大小_Javascript_Jquery_Css - Fatal编程技术网

Javascript 更改浏览器宽度上的li高度调整大小

Javascript 更改浏览器宽度上的li高度调整大小,javascript,jquery,css,Javascript,Jquery,Css,我制作了一个小脚本,将一组li元素的高度更改为内容最多的元素 代码工作正常,但也应该通过调整浏览器宽度来工作 我需要知道为什么不通过更改浏览器宽度来重新加载 这是我的密码: //changes slider hight to the hight of the li with the most content function heightChange() { var max = -1; $(".feedback li").each(function() { var

我制作了一个小脚本,将一组li元素的高度更改为内容最多的元素

代码工作正常,但也应该通过调整浏览器宽度来工作

我需要知道为什么不通过更改浏览器宽度来重新加载

这是我的密码:

//changes slider hight to the hight of the li with the most content
function heightChange() {
    var max = -1;
    $(".feedback li").each(function() {
        var h = $(this).height(); 
        max = h > max ? h : max;
    });
    $(".feedback li").css("height", max);
};

// start by open site
heightChange();

// load function by resizing of the browser window
$(window).bind("resize", function(){
    heightChange();
});

重新设置高度之前,需要重置高度

$(window).on("resize", function(){
     $(".feedback li").css("height", "auto");
    heightChange();
});
否则将
height()
仅返回指定值


另外,
.on()
是绑定和事件的首选方式,从jQuery 1.7开始,

您可以发布带有html和javascript的fiddlejs吗?如果更改宽度而不是高度,会发生什么?为什么您认为在第一次函数调用之后会发生这种情况?您在第一次调用时设置了
max=h
,然后
h
没有变化对我来说似乎绝对好,小提琴:对mee也很好一旦设置了高度,它也会在您的高度()方法中返回谢谢,就是这样!;-)