If I’m debugging some javascript code and I want to see where I am in the DOM, how can I print the entire element returned by (say) getElementById()? I know I can print a field:
attrib = document.getElementById("attrib-2");
alert(attrib.selectedIndex);
but if I want to print the whole thing (even children) what can I do?
Alert isn’t the best option for debugging purposes. Consider using some specifically designed tools like FireBug in Firefox, Developer Tools in WebKit browsers. Then use
console.logmethod to see some data you need in highly readable format.