简体   繁体   English

html文本区域可以包含只读文本和可编辑文本的组合吗

[英]Can a html text area have a combination of read only and editable text

this a is quite an open question regarding a <textarea> that is embedded within a form. 关于嵌入在表单中的<textarea> ,这是一个相当开放的问题。

Is at all possible to have read only text that can not be edited and then within the same <textarea> an option to start writing text. 完全有可能拥有只读的无法编辑的文本,然后在同一<textarea>一个选项可以开始编写文本。

My problem is that I can have only one or the other. 我的问题是我只能拥有一个。 If not is there any solutions to have a hard coded message appear in the <textarea> before the text can be written. 如果没有,则可以在<textarea>出现任何硬编码消息的解决方案,然后再编写文本。

Thanks for your time and sorry for the newbie sort or question. 感谢您的宝贵时间,对于新手的排序或问题深表歉意。

Can a html text area have a combination of read only and editable text html文本区域可以包含只读文本和可编辑文本的组合吗

No. 没有。

If not is there any solutions to have a hard coded message appear in the before the text can be written. 如果没有,则在写入文本之前,有任何解决方案可以使硬编码消息出现。

<p>The quick brown <input name="jumping_animal">
   jumped over the lazy <input name="lazy_animal">.</p>

Does it need to be a textarea? 是否需要是文本区域?

Try editing the blue text 尝试编辑蓝色文字

<div>
    sadsaasdfasd sadfasdf sa sd <span contenteditable>sadf asdf</span>
</div>

Yes you can't have both read only text with writable property for a textarea. 是的,您不能同时拥有一个文本区域的具有可写属性的只读文本。

Answer to your second question: 回答第二个问题:

<script>
    $('#input_textarea').focus(function() {
       if( $(this).val() == "Some text...." ) {
           $(this).val("");
       }           
    });
    $('#input_textarea').blur(function() {
       if( $(this).val() == "" ) {
           $(this).val('Some text....');
       }           
    });
</script>

This will work as a placeholder for your textarea. 这将用作您的文本区域的占位符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM