function integer_methods(){ var aArray=document.getElementById('wang').getElementsByTagName("em"); for(var i = 0;i < aArray.length; i++) { aArray[i].toFixed(0); //提示出错 TypeError: aArray[i].toFixed is not a function } }
I want to round the contents of all em tags under ID wang
toFixed
函数是Number
的方法。而aArray[i]
的类型是HTMLElement
。