JS. How to replace html element with another element/text, represented in string?

后端 未结 8 1013
清酒与你
清酒与你 2020-12-24 03:03

I have a problem with replacing html elements.

For example, here is a table:

0
8条回答
  •  [愿得一人]
    2020-12-24 03:40

    idTABLE.parentElement.innerHTML =  '123 element 456';
    

    while this works, it's still recommended to use getElementById: Do DOM tree elements with ids become global variables?

    replaceChild would work fine if you want to go to the trouble of building up your replacement, element by element, using document.createElement and appendChild, but I don't see the point.

提交回复
热议问题