部分锁定文本区域 [英] Partially lock Text Area

查看:70
本文介绍了部分锁定文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在'TEXTAREA'中的不可编辑的文本中绑定数据库,TEXTAREA的剩余部分应该是可编辑的。怎么做?? ?? div class =h2_lin>解决方案

请看我对这个问题的评论。



只需单独创建可编辑和不可编辑部分的元素,或者,如果需要,还有三个部分:不可编辑 - 可编辑 - 不可编辑。可编辑部分应为 textarea ,但不可编辑元素可以是只读 textarea ,文本输入元素(单行)或甚至更好的一些静态元素,例如 div p 。通过适当的样式,您可以使它们看起来光滑,同时,用户将有一个视觉线索,哪个部分是可编辑的,哪个不是。您可以删除所有边框,可以使用不同的颜色,布局等。



或者,还有另一种可能性,根本不使用输入元素,而是使用属性 contenteditable

HTMLElement.contentEditable - Web API | MDN [ ^ ]。



此属性可以与任何文本元素一起使用,并使其可编辑。使用这种方法,您甚至可以使用非块元素,因此它们将具有自由流动的布局。同样,这是造型的问题,但重要的是:它将消除 textarea 的限制。



< DD> -SA

Is it possible to non editable only texts inside a 'TEXTAREA' that are binding from database, remaining portion of the TEXTAREA should be editable. How to do that??

解决方案

Please see my comment to the question.

Just create separate elements for editable and non-editable parts, or, if you need to do so, three parts: non-editable-editable-non-editable. Editable part should be a textarea, but the non-editable elements can be read-only textarea, text input element (single-line) or, even better, some static element, such as div or p. With proper styling, you can make them look smooth and, at the same time, the user will have a visual clue one which part is editable and which is not. You can remove all borders, can use different coloring, layout, and so on.

Alternatively, there is another possibility, not using input elements at all, but using the attribute contenteditable:
HTMLElement.contentEditable — Web APIs | MDN[^].

This attribute can work with any text element and will make it editable. With this approach, you can even use non-block elements, so they will have freely flowing layout. Again, it's a matter of styling, but important thing is: it will remove limitations of textarea.

—SA


这篇关于部分锁定文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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