I'm trying to append a child to a td element. here is the HTML I am working with,
<td colspan="8" class="sectionExpandColumn courseResultLL courseResultLR">
    <a class="sectionExpand collapsibleCriteria" action=sectionDetail">
        sections
    </a>
  </td>
I want it to be,
<td colspan="8" class="sectionExpandColumn courseResultLL courseResultLR">
    <a class="sectionExpand collapsibleCriteria" action=sectionDetail">
        sections
    </a>
    <a class="sectionExpand collapsibleCriteria" action=sectionDetail">
        discussion
    </a>
  </td>
just simply addding a link tag under td, really.
so in my script,
div = table.getElementsByClassName("sectionExpandColumn");
var button = document.createElement("a");
button.setAttribute("class", "sectionExpand.collapsibleCriteria");
button.innerHTML = "Discussion";
div.appendChild(button);
I am getting Uncaught TypeError: div.appendChild is not a function Why is it?
Update
Thank you for telling me that I'm working with a htmlcollection!
So I added this code,
for (var i=0; i<div.length; i++){
    div[i].appendChild(button);
  }
But it runs through just fine, but at the end, it only adds the element to the last div. I'm trying to make a sense out of this... Could you tell me why?
 
     
     
     
    