开发者

how to place the default text in the <textarea>

开发者 https://www.devze.com 2023-01-09 09:17 出处:网络
i am try to place the default text in the textarea using the \'value\' property.But it is not working. please give me some solution for t开发者_运维知识库his.

i am try to place the default text in the textarea using the 'value' property.But it is not working. please give me some solution for t开发者_运维知识库his.


here it is ..

<textarea> default value here </textarea>

from the w3 on textarea

The TEXTAREA element creates a multi-line text input control. User agents should use the contents of this element as the initial value of the control and should render this text initially.


It should be:

<textarea>Default Text...</textarea>

It has not value property. You should put default text in between opening and closing tags.

Here is the W3C Specification for textarea

<!ATTLIST TEXTAREA
  %attrs;                              -- %coreattrs, %i18n, %events --
  name        CDATA          #IMPLIED
  rows        NUMBER         #REQUIRED
  cols        NUMBER         #REQUIRED
  disabled    (disabled)     #IMPLIED  -- unavailable in this context --
  readonly    (readonly)     #IMPLIED
  tabindex    NUMBER         #IMPLIED  -- position in tabbing order --
  accesskey   %Character;    #IMPLIED  -- accessibility key character --
  onfocus     %Script;       #IMPLIED  -- the element got the focus --
  onblur      %Script;       #IMPLIED  -- the element lost the focus --
  onselect    %Script;       #IMPLIED  -- some text was selected --
  onchange    %Script;       #IMPLIED  -- the element value was changed --
  >


For textarea elements, the default value goes between the tags. Like so:

<textarea name="bigtext">This is the text that will appear in the box.</textarea>


Provide it in the tag content instead:

<textarea>Default text</textarea>

To get or set the text using JavaScript, you will need to access the textContent or innerText properties:

if ("textContent" in myTextArea)
    alert(myTextArea.textContent);
else 
    alert(myTextArea.innerText);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号