要素の種類を調べる

alert( document.getElementById("hoge").nodeName );

テキストボックス等なら"INPUT"が、spanタグなら"SPAN"が返る。