jquery - For loop runs once, 2/3 of the way (javascript) -
function clearobjects() { var co = document.getelementsbyclassname("clearable"); var i; alert("function runs"); (i = 0; < co.length; i++) { alert("for loop runs 1/3"); alert("for loop runs 2/3, time erase"); co[i].style.backgroundcolor = "#ffffff"; alert("for loop runs 1, erased 1"); }; }; clearobjects();
this function has here suppose change color of divs class of clearable background color of white, "erased." function runs inside of other code, issue loop stops running when gets to:
co[i].style.backgroundcolor = "#ffffff";
i put alerts in there see parts of function run, , final alert "for loop runs 1, erased 1" not alert, , loop not run again. have looked , not find problem similar mine. know doing wrong? post of code if neccessary. thanks!
i fixed problem setting visibility hidden instead of background white, , setting class of new divs jquery's attr() function instead of had. works now, input!
Comments
Post a Comment