87,997
社区成员




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<script language="JavaScript">
function fetch(str, pos){
var arrText = str.split("\n");
if( arrText && pos > 0 && pos <= arrText.length ){
return arrText[pos-1];
}
return null;
}
</script>
<body>
<form>
<textarea rows="5" id="text1"></textarea>
<input type="text" id="txtPos" value=1>
<input type="button" value="test" onclick="alert( fetch(text1.value, txtPos.value));">
</form>
</body>
</html>
var s = "A\nBB\nCD\nE";
alert(s.split("\n")[2]);