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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -