im trying to change the padding of all the td in table. somehow it doesnt work. can you help ?
script ->
css ->
html ->
Advertisement
Answer
As Martin said in the comments ID’s are unique selectors, so for apply style for td tag in script, you can use some thing like this:
<script> let td = document.getElementsByTagName('td'); for (i = 0; i < td.length; i++) { td[i].style.padding = "20px"; } </script>
or change Id to class: strHtml += '<td class="curr-cell">'
and use document.getElementsByClassName('curr-cell')
in above code.