概述
要求如下:1,我只选择了第一行的某个数字,那么alert的时候,要把第一行所有的数字alert出来..
2,如果选择多行,最后一行没有选择完毕,那么最后一行的全部的数字也要被alert出来
3,选择多行后,能够不受滚动条的影响
<html>
<head>
<style type="text/css">
</style>
<META http-equiv="content-type" content="text/html; charset=shift_jis">
<title>TEST</title>
</head>
<LINK rel="stylesheet" href="../css/table.css" type="text/css" id="_HPB_TABLE_CSS_ID_">
<script type="text/javascript">
function start_fresh(){
var oV = 0;
var nV = 0;
var rng = document.getElementById("textAr").createTextRange();
var r1 = document.selection.createRange();
var r2 ;
oV = r1.boundingHeight;
nV = r1.boundingHeight;
if (r1.parentElement().name == "textAr"){
while(oV == nV){
r2 = r1.duplicate();
r2.moveEnd("character",1);
nV = r2.boundingHeight;
if (oV == nV){
r1.moveEnd("character",1);
}
}
r1.select();
}
oV = r1.boundingHeight;
nV = r1.boundingHeight;
if (r1.parentElement().name == "textAr"){
while(oV == nV){
r2 = r1.duplicate();
r2.moveStart("character",-1);
nV = r2.boundingHeight;
if (oV == nV){
r1.moveStart("character",-1);
}
}
r1.select();
}
}
</script>
</head>
<body bgcolor= "#ffffff">
<form method="post" action="" name="FMlog">
<table>
<tr><td>
<input type = button value = "Config" onclick = "start_fresh()">
</td></tr>
<tr><td>
<textarea name = "textAr" rows = "5" cols = "100">
123424323423
56782342423
98762342423
9876523423423
56782342423
98762342423
9876523423423
</textarea>
</td>
</tr>
</table>
</form>
</body>
</html>
最后
以上就是可耐蓝天为你收集整理的textarea 获取行的值的全部内容,希望文章能够帮你解决textarea 获取行的值所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复