Javascript随机无法对项目进行排序,没有错误
javascript randomly fails to sort items, no error
由于某些原因,Javascript会随机停止工作。
处理高度问题的代码:
$(document).ready(function()
{
/*setEqualHeight($("ul#product_list li"));*/
//alert("some text");
/*setEqual($("ul#product_list"));*/
//var i = 2;
//alert($('ul#product_list li:nth-child('+ (i + 2) +')').height()); //this is correct way to get value*/
var elements = $('ul#product_list li').length; //this is correct way to get value
/*var liekana = elements % 3;
elements = elements - liekana;
alert(elements);*/
for(var i = 1; i <= elements; i = i + 3)
{
var first = $('ul#product_list li:nth-child('+ (i) +')').height();
var second = $('ul#product_list li:nth-child('+ (i + 1) +')').height();
var third = $('ul#product_list li:nth-child('+ (i + 2) +')').height();
var tallest = 0;
if (first > second)
if (first > third)
{
tallest = first;
}
else
{
tallest = third;
}
else
if (second > third)
{
tallest = second;
}
else
{
tallest = third;
}
$('ul#product_list li:nth-child('+ (i) +')').height(tallest);
$('ul#product_list li:nth-child('+ (i + 1) +')').height(tallest);
$('ul#product_list li:nth-child('+ (i + 2) +')').height(tallest);
/*if (!third)
alert("yra");*/
}
});
URL: http://piguskompiuteris.lt/6_asus正常渲染URL: http://piguskompiuteris.lt/16-lenovo
对于如何解决这个问题,任何建议都将非常感谢。由于更新2。我重写了javascript代码…我还是会得到相同的随机错误,有时网格会崩溃。我不确定原因是什么。
可能的原因:1) Height属性太小,不包括Height + padding + margin + border2)函数位置有问题(目前不在header中)或调用它$(document).ready(function()
我检查了你的网站。并找到了这个解决方案,使用它:
columns.height(tallestcolumn);
将以上代码替换为以下代码:
columns.css("min-height", tallestcolumn+" !imporatant");
排序脚本工作
修改脚本:
$(窗口).load(函数(){});
Out代替:
$(文档)时(函数(){});
相关文章:
- 回复'js'仅当请求有错误时(否则使用html)
- 表单已发送,但验证有错误
- 如果文件不存在,fs.watch是否有错误处理程序
- Meteor上有错误的同步问题
- 表单验证:如果有错误,不要't使手风琴动起来
- Javascript排序函数错误地更改了元素'数组中的位置
- JavaScript 排序顺序错误
- 我有错误文档.注册元素未被细化
- 如何转换为特定于 json 的类 c#?我有错误
- 如果当前输入有错误或警告,则禁用所有下一个表单输入字段
- 通过有错误的 Ajax-Request 打印出 HTML 会阻止进一步的 JS 工作
- 脸书应用程序有错误
- XDomainRequest 总是有错误
- HTML5 Canvas游戏有错误,点击时第一个拼图块会变成不同的块
- Page_ClientValidate返回 false,但没有一个验证器有错误
- 量角器由中继器命令中是否有错误
- Jquery 验证器 - 表单被保存但有错误
- 任何人看到我的重置功能有错误
- 现在我有错误“;ReferenceError:项未定义“;不知道如何测试我的dataService
- 有没有一种方法可以在加载页面后检查iframe是否有错误消息