悠然哈哈哈

导航

双击tr获取td

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript">
function clickTR(n)
{
var a=document.getElementById("td"+n+"1").innerText;
var b=document.getElementById("td"+n+"2").innerText;
var c=document.getElementById("td"+n+"3").innerText;
var d=document.getElementById("td"+n+"4").innerText;
alert("编号:"+a+"\n姓名:"+b+"\n性别:"+c+"\n年龄:"+d);
}
</script>
</head>

<body>
<table width="98%" border="1" cellspacing="0" cellpadding="0">
<tr align="center">
<td width="25%">编号</td>
<td width="25%">姓名</td>
<td width="25%">性别</td>
<td width="25%">年龄</td>
</tr>
<tr align="center" onclick="clickTR(1);">
<td id="td11">1</td>
<td id="td12">王中央</td>
<td id="td13">男</td>
<td id="td14">23</td>
</tr>
<tr align="center" onclick="clickTR(2);">
<td id="td21">2</td>
<td id="td22">赵四娣</td>
<td id="td23">女</td>
<td id="td24">32</td>
</tr>
</table>
</body>
</html>

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script language="javascript" type="text/javascript">
$(function(){
//使用jquery 取得table 中td里面的值
$("#tb tbody td").dblclick(function(){
/*alert($(this).parent(this).text());
alert($(this).parent(this).children("td").eq(0).text());
alert($(this).parent(this).children("td").eq(1).text());
alert($(this).parent(this).children("td").eq(2).text());
*/
var td1=$(this).parent(this).children("td").eq(0).text();
var td2=$(this).parent(this).children("td").eq(2).text();
alert(td2);
var array=new Array();
array.push(td1);
array.push(td2);
alert(array);
})
});

</script>
</head>

<body>
<table id="tb" style="text-align: center;" width="100%" border="1PX">
<thead>
<tr> <td>A哈1</td><td>A哈2 </td> <td>A哈3</td> </tr>
</thead>
<tbody>
<tr> <td>A1 </td><td> A2 </td> <td>A3</td> </tr>
<tr><td>B1</td> <td> B2</td><td>B3</td> </tr>
<tr><td>C1</td> <td> C2</td><td>C3</td> </tr>
</tbody>
</table>
</body>
</html>

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body{ font-size:14px;}
input{ vertical-align:middle; margin:0; padding:0}
.file-box{ position:relative;width:340px}
.txt{ height:22px; border:1px solid #cdcdcd; width:180px;}
.btn{ background-color:#FFF; border:1px solid #CDCDCD;height:24px; width:70px;}
.file{ position:absolute; top:0; right:80px; height:24px; filter:alpha(opacity:0);opacity: 0;width:260px }
</style>
</head>

<body>
<div class="file-box">
<form action="" method="post" enctype="multipart/form-data">
<input type='text' name='textfield' id='textfield' class='txt' />
<input type='button' class='btn' value='浏览...' />
<input type="file" name="fileField" class="file" id="fileField" size="28"
onchange="document.getElementById('textfield').value=this.value" />
<input type="submit" name="submit" class="btn" value="上传" />
</form>
</div>
</body>
</html>

 

 

 

 

 

 

 

 

 

----来源忘记了,请见谅

posted on 2015-02-03 14:54  悠然886  阅读(299)  评论(0编辑  收藏  举报