Rendering HTML inside textarea

后端 未结 7 2085
孤独总比滥情好
孤独总比滥情好 2020-11-22 01:34

I need to be able to render some HTML tags inside a textarea (namely , , , ) but textareas only interpret their content as text. Is

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 02:09

    This is not possible to do with a textarea. What you are looking for is an content editable div, which is very easily done:

    jsFiddle

    div.editable {
        width: 300px;
        height: 200px;
        border: 1px solid #ccc;
        padding: 5px;
    }
    
    strong {
      font-weight: bold;
    }
    This is the first line.
    See, how the text fits here, also if
    there is a linebreak at the end?
    It works nicely.

    Great.

提交回复
热议问题