Artem
Artem

Reputation: 11

While doesn't work

function Sort(td)
{
    var t=document.getElementById("theList");
    var rows=t.getElementsByTagName("td");
    var cells=t.cells;
    var bb=true;
    while(bb==true)
    {
    alert(bb);
      for(var i=1;i<rows.length;i++)
       {
           if(cells[td.cellIndex+i*4].innerText<cells[td.cellIndex+(i+1)*4].innerText)
            {

            }
        }
    alert("Works"); //this alert is not reached
    }
}

The second alert will not be shown. Can you tell me why?

Upvotes: 1

Views: 141

Answers (2)

Robusto
Robusto

Reputation: 31883

Your var rows is an array, which will not have a property "cells". That could be your problem right there.

Upvotes: 2

Cogwheel
Cogwheel

Reputation: 23217

If something goes wrong in any of the code in the for loop it won't reach the second alert. I'd suggest running this in a JS debugger.

Upvotes: 0

Related Questions