string UserName = (TextBox)rowCells[0]Controls[0])TextToString();
UserName 就是。var tds = documentgetElementsByName(“td”);
var tdValue = tds[1]innerText;//这个 tds[1]表示取得tds这个数组中的2号位置(td标签)的值,这里就是
alert(tdValue );
<table border="1" cellspacing="0" id="mytable">
<thead>
<caption>统计表</caption>
</thead>
<tbody>
<tr>
<th>编号</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>籍贯</th>
</tr>
<tr>
<td>1</td>
<td>张三</td>
<td>男</td>
<td>22</td>
<td>北京</td>
</tr>
<tr>
<td>2</td>
<td>李四</td>
<td>男</td>
<td>23</td>
<td>上海</td>
</tr>
<tr>
<td>3</td>
<td>王燕</td>
<td>女</td>
<td>21</td>
<td>广东</td>
</tr>
<tr>
<td>4</td>
<td>王伟</td>
<td>男</td>
<td>20</td>
<td>陕西</td>
</tr>
<tr>
<td>5</td>
<td>张娟</td>
<td>女</td>
<td>23</td>
<td>重庆</td>
</tr>
</tbody>
</table>
<script>
$(function(){
var name=$("#mytable tr>td:nth-child(2)")text();
var age=$("#mytable tr>td:nth-child(3)")text();
alert(name);
alert(age);
});
</script>
请参考已存在的帖子
可以用delegate来做
<html><head>
<script type="text/javascript" src="/jquery/jqueryjs"></script>
<script type="text/javascript">
$(document)ready(function(){
$('#test')delegate('li','click',function(){
alert($(this)text());
});
});
</script>
</head>
<body>
<ul id="test">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</body>
</html>
这是一个示例,你可以参考一下,点击<li>会跳出d框显示对应li的内容
<td align="center" valign="top" title="zxd" id="aa"></td>
var id = documentgetElementById("aa");
var t = idtitle;var trs = documentgetElementsByTagName("tr");
for(var i=0;i<trslength;i++){
trs[i]onclick=function(){
var tds=thisgetElementsByTagName("td");
consolelog("ID: "+tds[0]getElementsByTagName("a")[0]innerHTML);
consolelog("Name: "+tds[1]innerHTML);
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)