getElementsByTagName return a HTMLcollection, So you need to pass the index of the element on which you want to add the event, or loop over the collection to add the event to each of the element
function test(){
// selecting only first element from the collection
var td = document.getElementsByTagName("td")[0];
td.addEventListener('mouseenter', function(){
td.style.background = "green";
});
}
test();
Adding addListener to all elements in the collection
function test(){
var cells = table.getElementsByTagName("td");
for (var i = 0; i < cells.length; i++) {
cells[i].addEventListener('mouseenter', function(){
this.style.background = "green";
});
}};
test()