does <textarea> auto-encode inner html?

后端 未结 2 441
失恋的感觉
失恋的感觉 2021-01-18 05:45

I was trying to print some text between tags, but I\'ve noticed that if I input some characters like &

相关标签:
2条回答
  • 2021-01-18 06:27

    The dom element should have properties like this:

    innerHTML = '&lt;script&gt;'
    
    innerText = '<script>'
    
    0 讨论(0)
  • 2021-01-18 06:32

    It doesn't escape the contents. The HTML source remains exactly the same. It just has the capability to display the contents as is which I guess is a requirement of the <textarea> tag.

    0 讨论(0)
提交回复
热议问题