在DIV中访问textarea的最佳方式 [英] Best way to access a textarea within a DIV
问题描述
你好
我有一个包含各种元素的DIV,例如:
< div ARID =" 8" ARType = QUOT;字符" ARDBN =简短描述>
< label class =" label f9" for =" arid8" Short Description< / label>
< textarea class =" text sr"包裹= QUOT;脱" ID = QUOT; arid8" rows = 1>< / textarea>
< / div>
我有一个变量div,包含DIV'和div [x]包含
我需要的实际DIV。
访问内部文本区域的最佳(或最强大)方式是什么?
因为我想在textarea字段中添加一些文本。我知道怎么用
添加文字,但想知道访问textarea的最佳方式。
Angus
2007年4月20日03:51:03 -0700,在comp.lang.javascript中Angus
< an ****** ***@gmail.com>
< 11 ********************* @ b75g2000hsg.googlegroups。 comwrote:
> |你好
|
|我有一个有各种元素的DIV,例如:
|
| < div ARID =" 8" ARType = QUOT;字符" ARDBN =简短描述>
| < label class =" label f9" for =" arid8"简短说明< / label>
| < textarea class =" text sr"包裹= QUOT;脱" ID = QUOT; arid8" rows = 1>< / textarea>
| < / div>
|
|我有一个变量divs,其中包含DIV'和divs [x]包含
|我需要的实际DIV。
|
|什么是访问内部文本区域的最佳(或最强大)方式 -
|因为我想在textarea字段中添加一些文本。我知道如何
|添加文本,但想知道访问textarea的最佳方式。
假设id是唯一的:
var txt = document.getElementById(" arid8")。value;
BTW为什么你使用< textarea /而不是< input type =" text" /?
---------------------------------------- -----------------------
jn ******@yourpantsyahoo.com.au :脱掉裤子回复
-------------------- -------------------------------------------
>>访问内部文本区域的最佳(或最强大)方式是什么 -
>>因为我想在textarea字段中添加一些文字。我知道如何添加文本但想知道访问textarea的最佳方式。
假设id是唯一的:
var txt = document.getElementById(" arid8")。value;
BTW为什么你使用< textarea /而不是< input type =" text" /?
为什么输入字段优于textarea?
4月20日12:30, Jeff North< jnort ... @ yahoo.com.auwrote:
2007年4月20日03:51:03 -0700,in comp.lang.javascript Angus
< anguscom ... @ gmail.com>
< 1177066263.052565.83 ... @ b75g2000hsg.googlegroups。 comwrote:
|您好
|
|我有一个包含各种元素的DIV,例如:
|
| < div ARID =" 8" ARType = QUOT;字符" ARDBN =简短描述>
| < label class =" label f9" for =" arid8"简短说明< / label>
| < textarea class =" text sr"包裹= QUOT;脱" ID = QUOT; arid8" rows = 1>< / textarea>
| < / div>
|
|我有一个变量div,其中包含DIV'和div [x]包含
|我需要的实际DIV。
|
|什么是访问内部文本区域的最佳(或最强大)方式 -
|因为我想在textarea字段中添加一些文本。我知道如何
|添加文本,但想知道访问textarea的最佳方式。
假设id是唯一的:
var txt = document.getElementById(" arid8")。value;
BTW为什么你使用< textarea /而不是< input type =" text" /?
---------------------------------------- -----------------------
jnort ... @ yourpantsyahoo.com.au:脱掉裤子回复
--------------------------------------------- ------------------
如果你试试html样本,var txt =
document.getElementById(" arid8")。value;不行。在IE或FF中没有工作
。
它应该可以工作,但似乎没有。所以我的下一个想法是怎么可以
我得到的DIV的子元素我知道包含textarea?
textarea是这样用户可以输入多个文本行。
Hello
I have a DIV with various elements eg:
<div ARID="8" ARType="Char" ARDBN="Short Description">
<label class="label f9" for="arid8"Short Description</label>
<textarea class="text sr " wrap="off" id="arid8" rows=1></textarea>
</div>
I have a variable, divs, which contains the DIV''s and divs[x] contains
the actual DIV I need.
What is the best (or most robust) way to access the inner textarea -
because I want to add some text to the textarea field. I know how to
add the text but want to know best way to access the textarea.
Angus
On 20 Apr 2007 03:51:03 -0700, in comp.lang.javascript Angus
<an*********@gmail.com>
<11*********************@b75g2000hsg.googlegroups. comwrote:
>| Hello
|
| I have a DIV with various elements eg:
|
| <div ARID="8" ARType="Char" ARDBN="Short Description">
| <label class="label f9" for="arid8"Short Description</label>
| <textarea class="text sr " wrap="off" id="arid8" rows=1></textarea>
| </div>
|
| I have a variable, divs, which contains the DIV''s and divs[x] contains
| the actual DIV I need.
|
| What is the best (or most robust) way to access the inner textarea -
| because I want to add some text to the textarea field. I know how to
| add the text but want to know best way to access the textarea.Assumng that the id is unique:
var txt = document.getElementById("arid8").value;
BTW why are you using a <textarea /and not <input type="text" /?
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
>>What is the best (or most robust) way to access the inner textarea ->>because I want to add some text to the textarea field. I know how
to add the text but want to know best way to access the textarea.
Assumng that the id is unique:
var txt = document.getElementById("arid8").value;
BTW why are you using a <textarea /and not <input type="text" /?Why would an input field be preferable to a textarea?
On 20 Apr, 12:30, Jeff North <jnort...@yahoo.com.auwrote:On 20 Apr 2007 03:51:03 -0700, in comp.lang.javascript Angus
<anguscom...@gmail.com>
<1177066263.052565.83...@b75g2000hsg.googlegroups. comwrote:| Hello
|
| I have a DIV with various elements eg:
|
| <div ARID="8" ARType="Char" ARDBN="Short Description">
| <label class="label f9" for="arid8"Short Description</label>
| <textarea class="text sr " wrap="off" id="arid8" rows=1></textarea>
| </div>
|
| I have a variable, divs, which contains the DIV''s and divs[x] contains
| the actual DIV I need.
|
| What is the best (or most robust) way to access the inner textarea -
| because I want to add some text to the textarea field. I know how to
| add the text but want to know best way to access the textarea.
Assumng that the id is unique:
var txt = document.getElementById("arid8").value;
BTW why are you using a <textarea /and not <input type="text" /?
---------------------------------------------------------------
jnort...@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------if you try the html sample, var txt =
document.getElementById("arid8").value; doesn''t work. Didn''t work
either in IE or FF.
It should work but it doesn''t seem to. So my next thought is how can
I get the child elements of the DIV that I know contains the textarea?
the textarea is so users can enter multiple lines of text.
这篇关于在DIV中访问textarea的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!