javascript - Applying padding on td element throwing exception -
i have declared variable padding
, in alert gives value without problems. however, when use:
document.getelementsbytagname("td").style.height = padding;
i error uncaught typeerror: cannot set property 'height' of undefined index.html:46 (anonymous function)
!
and while padding
correct value!!!
what now, wrong!?
note: index.html:46 line shown above.
document.getelementsbytagname("td")
returns nodelist
, , array
, can do:
document.getelementsbytagname("td")[0].style.height = padding;
or in loop:
var tds = document.getelementsbytagname("td"); for(var i=0 , len = tds.length; i<len; i++){ tds[i].style.height = padding; }
Comments
Post a Comment