开发者

innerHTML doesn't interpret HTML tags

开发者 https://www.devze.com 2023-03-11 04:30 出处:网络
I\'m trying to replace the contents of a div with some piece of HTML. However the html is not interpreted. If error[0].childNodes[0].nodeValue contains blah <strong>foobar</strong> then I

I'm trying to replace the contents of a div with some piece of HTML. However the html is not interpreted. If error[0].childNodes[0].nodeValue contains blah <strong>foobar</strong> then I will see <strong> in the output. How can I fix this?

document.getElemen开发者_如何学PythontById("booking").innerHTML = "Server error: " + error[0].childNodes[0].nodeValue;


Is perhaps error[0].childNodes[0].nodeValue escaped? you could try:

document.getElementById("booking").innerHTML = "Server error: " + unescape(error[0].childNodes[0].nodeValue); 
0

精彩评论

暂无评论...
验证码 换一张
取 消