textarea自动换行的换行符是什么?
js中如何获得textarea的换行符?
<textarea id= "txtTest " WRAP= "hard " style= "width:200px "> </textarea>
当输入的内容自动换行之后,能否获得自动换行的换行符?
txtTest.value.indexOf( "\n ") 等于 -1,txtTest.value.indexOf( "\r ")也是等于-1
谢谢!
------解决方案--------------------
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> new page </title>
<script>
function a(){
alert(document.getElementById( "t ").innerText.replace( "\r\n ", "$ "));//回车换行换成 "$ "
}
</script>
</head>
<body>
<textarea id=t> </textarea>
<input type=button onclick= "a() " value= "ok ">
</body>
</html>