使用contentEditable div而不是textarea有什么缺点? [英] What are the cons of using a contentEditable div rather than a textarea?

查看:218
本文介绍了使用contentEditable div而不是textarea有什么缺点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会使用属性 contentEditable =true作为文本字段而不是textarea的div来拍摄自己的脚吗?

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

推荐答案

它会工作得很好,但它会比表单更难一点,必须连接你自己的逻辑,使按钮的点击事件跟踪正确的div,获取其内容,然后执行提交。 textarea的优点是浏览器会为你处理所有这些。

It would work fine, but it'd be a little bit more difficult than a form, simply because you're going to have to wire up your own logic to make the button's click event track down the correct div, get its content, and then perform the submission. The advantage of a textarea is that the browser takes care of all that for you.

这篇关于使用contentEditable div而不是textarea有什么缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆