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

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

I have a problem with replacing html elements.

For example, here is a table:

';
$('#__TABLE__').replaceWith(str);

http://jsfiddle.net/hZBeW/4/

Or in pure javascript:

var str = '
'; var tdElement = document.getElementById('__TABLE__'); var trElement = tdElement.parentNode; trElement.removeChild(tdElement); trElement.innerHTML = str + trElement.innerHTML;

http://jsfiddle.net/hZBeW/1/

提交回复
热议问题
0
8条回答
12 12