How to insert HTML as Text

前端 未结 5 1669
无人及你
无人及你 2020-12-09 20:03

I want HTML, for example,

, to show show as just that, in plain text, and not interpreted by the browser as an actual tag.

I know JQuery has .h

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 21:02

    You can use aslo innerText from most of DOM elements:

    document.getElementById('some').innerText = "There can be  even HTML tags ";
    

    The tags will not be formatted. You can aslo use \n for new line and more codes (\t, \u2623...). If you want aslo to use fixed-size characters you can use easy

     tag.

提交回复
热议问题