JavaScript & copy style

前端 未结 3 1467
南笙
南笙 2020-12-19 04:39

I am copying a table cell with javascript.

It works fine, just that it doesn\'t copy the style. I wanted to copy like below, but that didn\'t work. newCell.style=old

3条回答
  •  -上瘾入骨i
    2020-12-19 04:57

    To copy all style elements from one node to another you can use

    newCell.setAttribute('style', oRow.cells[1].getAttribute('style'))
    

提交回复
热议问题