textarea值的输入与取得的问题! it should be changed into "\r" not "\n"and you should get the textarea's value by using this method belowdocument.getElementsByTagName("textarea")[0].innerHTML 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 document.getElementsByTagName("textarea")[0].innerHTML innerHTML啊,我去试试看能不能解决这个问题,貌似可以。解决后结贴^^ 貌似不能?document.getElementsByTagName("textarea")[0].innerHTML = "asddsa";出错啊怎样才能附多行值给变量?或者怎样取得textarea的值为单行?下面在ff下没用吧?<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script language=javascript> function as(){ alert(document.getElementsByTagName("textarea")[0].innerHTML); } </script> </head><body> <textarea id="ta1" name="ta1" COLS="70" ROWS="8" ></textarea> <input type="button" onclick="as()"> 
</body> </html> no.. the error is occurred by the document.getElementsByTagName("textarea")[0] <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body> <textarea id="ta1" name="ta1" COLS="70" ROWS="8" ></textarea> <input type="button" onclick="as()"> 
 <div id="div1"> <script language=javascript> function as(){ var txt=document.getElementById("ta1").value; alert(escape(txt)); var div1=document.getElementById("ta2"); ta2.value=txt } </script> </div1> <textarea id="ta2" name="ta2" COLS="70" ROWS="8" ></textarea></body> </html>用replace替换就对了,试着输入不同格式的内容,看看上面alert之后会显示什么就明白了 sorry, maybe you can try this.<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script language="javascript">var node;function as(){node=document.getElementById("ta1");alert(node.value);node.value="new";}</script></head><body><textarea id="ta1" name="ta1" COLS="70" ROWS="8" ></textarea><input type="button" value="got the value" onclick="as()">
</body></html> 结果自己解决了当textarea多行时,换行自动有个\r\n,只是显示不出来只要在取值后把其转了就行了谢谢大家,顶者有分 estJS动态生成树问题求助 html网页中用js 读取cookies 代码并且发送到指定邮箱 js中有什么事件页面是打开而不是刷新? (新手求助)一组图片的显示 求javascript 防止客户端学习挂机脚本 在线编辑器图文混排问题 如何让页面载入完成后自动滚动到上一个页面的滚动位置?? 如何判断记录位置? 最近公司在用ExtJs4.1,谁能给我推荐几本好的书籍?最好能下到电子版的 Jquery-1.11.1.min.js中Date对象未定义 透明的图片 请教,如何在js中判断一个输入是否数字。
document.getElementsByTagName("textarea")[0].innerHTML = "asd
dsa";
出错啊怎样才能附多行值给变量?
或者怎样取得textarea的值为单行?下面在ff下没用吧?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language=javascript>
function as(){
alert(document.getElementsByTagName("textarea")[0].innerHTML);
}
</script>
</head>
<body>
<textarea id="ta1" name="ta1" COLS="70" ROWS="8" ></textarea>
<input type="button" onclick="as()">


</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head>
<body>
<textarea id="ta1" name="ta1" COLS="70" ROWS="8" ></textarea>
<input type="button" onclick="as()">


<div id="div1">
<script language=javascript>
function as(){
var txt=document.getElementById("ta1").value;
alert(escape(txt));
var div1=document.getElementById("ta2");
ta2.value=txt
}
</script>
</div1>
<textarea id="ta2" name="ta2" COLS="70" ROWS="8" ></textarea>
</body>
</html>用replace替换就对了,试着输入不同格式的内容,看看上面alert之后会显示什么就明白了
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script language="javascript">var node;function as(){
node=document.getElementById("ta1");
alert(node.value);
node.value="new";
}</script>
</head>
<body>
<textarea id="ta1" name="ta1" COLS="70" ROWS="8" ></textarea>
<input type="button" value="got the value" onclick="as()">


</body>
</html>
当textarea多行时,换行自动有个\r\n,只是显示不出来
只要在取值后把其转了就行了谢谢大家,顶者有分