What are the cons of using a contentEditable div rather than a textarea?

后端 未结 3 1136
离开以前
离开以前 2020-12-29 18:22

Would I be shooting myself in the foot by using a div with attribute contentEditable=\"true\" as a text field rather than a textarea?

3条回答
  •  温柔的废话
    2020-12-29 18:36

    The Gmail's mail edit box is also a div with contenteditable="true". The major benefit is it has auto-adjust height as user input text/content. Also it supports rich text inside. You can mimic the Textarea by setting a max height if need.

    On the other hand if you want auto height in Textarea, you might have to use js to bind some listener to the oninput hook.

提交回复
热议问题