0
我想用動態創建的元素替換佔位符。javascript - 用動態創建的元素替換字符串
方法
var myhtml = 'some html and stuff {IMAGE} some more html';
myhtml = myhtml.replace(/{IMAGE}/g, document.createElement('img'));
console.log(myhtml); // some html and stuff [object HTMLImageElement] some more html
我怎樣才能使它所以它與實際的HTML輸出代替它?
提前致謝!
抱歉,這不是我所要求的。我知道我可以追加它,但我需要把它放在特定的地方。 – n00b 2011-02-07 11:46:08