gpt4 book ai didi

javascript - firefoxs 几乎因这段代码而崩溃。它似乎有效但不是真的

转载 作者:行者123 更新时间:2023-11-30 18:44:28 26 4
gpt4 key购买 nike

window.onload = raknaUtMedelvarde;

function raknaUtMedelvarde(){

var tabell = document.getElementById("temperaturtabell");
var rader = tabell.getElementsByTagName("tr");

for (var i = 0; i < rader.length; i++){
var tabellceller = rader[i].getElementsByTagName("td");
//alert(tabellceller.length);
//räkna ut medelvärde
var medel = medelVarde(tabellceller);
//alert(medel);
var medelText = document.createTextNode(medel);
var medelElement = tabellceller [tabellceller.length - 1];
medelElement.appendChild(medelText);


}
}

function medelVarde(celler){
var summa = 0;
for (var i = 1; i < celler.length - 1; i++){

var nuvarandeVarde = celler[i].firstChild.nodeValue;
summa = summa + parseInt(nuvarandeVarde);
}
return summa / 5;
}
// code behind "visa värde" (show the value)
//I think here somewhre is the problem?

function hitta(){

var varde = parseInt(document.getElementById("varde").value);
var tabell = document.getElementById("temperaturtabell");
var rader = tabell.getElementsByTagName("tr");

for ( var i = 0; i < rader.length; i++){

var tabellceller = rader[i].getElementsByTagName("td");
// checkpoint to see is the values is >= then the enter value
if(haVarde (varde, tabellceller))
rader[i].className = "emp";


}
}

// boolean method to check the value
function haVarde(varde, celler){
var harVarde = false;
var sum = 0;
for (var i = 1; i = celler.length -1; i++){

var nuvarandevarde = parseInt(celler[i].firstChild.nodeValue);
if ( nuvarandevarde >= varde)
{
harVarde = true;
celler[i].className = "emptd";
}
}
return harVarde;
}

你好!

我正在编写这段代码。此刻我尝试用表中的总数据检查该值。 FF 开始崩溃有点像说..我有问题不知道在哪里请查看消息:http://dl.dropbox.com/u/3632213/what.jpg ...mm,mm 无法理解消息...任何建议都欢迎! :)

最佳答案

这一行:

for (var i = 1; i = celler.length -1; i++){

会导致死循环。

你的意思可能是 <= ?

关于javascript - firefoxs 几乎因这段代码而崩溃。它似乎有效但不是真的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5868353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com