Internet Explorer 8 and each() problem

Internet Explorer 8 and each() problem

I have been trying to create a function that creates a table of content automatically. It works nicely on Firefox 3.6, but not on Internet Explorer 8.

The problem seems to be that the each() method is not executed on IE. It is skipped with no errors.
I have tested the each() method on IE 8 before and it seems to work, but not on this occasion.

I am using jQuery 1.4.2. Below is the code.


  1.  var container = $("div#tocContainer");
     var headerText = container.attr("title");
     $("<h1>", { id: "tocHeader", text: headerText }).appendTo(container);
                
     var list = $("<ul>", { id: "tocList" });
     list.appendTo(container);

     $(":header").each(function () {
           if ($(this).attr("id") != "tocHeader") {
                 var itemText = $(this).text().trim();
                 $("<li>", { text: itemText }).appendTo(list);
           }
     });