cambia
htext=ths[i].firstChild.nodeValue;
in
htext=ths[i].id;