Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用默认文本创建文本区域_Javascript_Html_Textarea - Fatal编程技术网

Javascript 使用默认文本创建文本区域

Javascript 使用默认文本创建文本区域,javascript,html,textarea,Javascript,Html,Textarea,我想知道有谁能帮上忙。 我正在通过phonegap制作一个Java编译器应用程序,我有一个textarea,我只希望Java类名已经默认在文本框中(并且不会消失) 因此,我有以下几点 <div> <label for="source">Source Code:</label> <textarea cols="35" rows="10" name="source" id="source" value=

我想知道有谁能帮上忙。 我正在通过phonegap制作一个Java编译器应用程序,我有一个textarea,我只希望Java类名已经默认在文本框中(并且不会消失)

因此,我有以下几点

    <div>
            <label for="source">Source Code:</label>
            <textarea cols="35" rows="10" name="source" id="source" value="class TryMe{"></textarea>
        </div>

        <div>
            <label for="input">Input: <span class="description">(Data that will be given to the program on the stdin.)</span></label>
            <textarea cols="35" rows="3" name="input" id="input"></textarea>
        </div>

        <div>

源代码:
输入:(将在stdin上提供给程序的数据。)
为了强调我的意思,我添加了“value=”class TryMe{”,以便您了解我的意思。
创建javascript函数最简单。

为html
设置默认值如下

<textarea cols="35" rows="10" name="source" id="source">  VALUE HERE  </textarea>
这里的值

文本区域没有值属性。只需在元素中添加文本即可

<textarea>class TryMe{</textarea>
类TryMe{
也可以使用占位符

<textarea placeholder="class TryMe{"></textarea>


非常感谢,是吗?当它工作时,文本会出现在文本框的中心,你知道为什么吗?你需要将所有文本都放在一行上,textarea值内的任何空白也会被呈现。这包括在textarea输入内容上的新行标记,它有很多空白吗?是的,我刚刚在en中使用了 ; d、 谢谢:)可能的副本