展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<script src="jquery-1.6.4.min.js"></script>
<script>
$(function(){
$('td').click(function(){
alert($('tr:first>td:eq('+$(this).index()+')').html());
})
})
</script>
</head>
<body>
<table>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<title> New Document </title>
<script src="jquery-1.6.4.min.js"></script>
<script>
$(function(){
$('td').click(function(){
alert($('tr:first>td:eq('+$(this).index()+')').html());
})
})
</script>
</head>
<body>
<table>
<tr>
<td>a</td>
<td>b</td>
<td>c</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>
</body>
</html>
展开全部
<html>
<head>
<title></title>
<script type="text/javascript" src="JS/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(function () {
var index, search;
search = "c";
$("#table tr:eq(0) td").each(function (i) {
if ($.trim($(this).html()) == search) {
index = i;
}
})
alert($("#table tr:eq(1) td:eq(" + index + ")").html());
})
</script>
</head>
<body>
<form id="form1" runat="server">
<table id="table">
<tr>
<td>
a
</td>
<td>
b
</td>
<td>
c
</td>
<td>
d
</td>
</tr>
<tr>
<td>
2
</td>
<td>
3
</td>
<td>
4
</td>
<td>
5
</td>
</tr>
</table>
</form>
</body>
</html>
<head>
<title></title>
<script type="text/javascript" src="JS/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(function () {
var index, search;
search = "c";
$("#table tr:eq(0) td").each(function (i) {
if ($.trim($(this).html()) == search) {
index = i;
}
})
alert($("#table tr:eq(1) td:eq(" + index + ")").html());
})
</script>
</head>
<body>
<form id="form1" runat="server">
<table id="table">
<tr>
<td>
a
</td>
<td>
b
</td>
<td>
c
</td>
<td>
d
</td>
</tr>
<tr>
<td>
2
</td>
<td>
3
</td>
<td>
4
</td>
<td>
5
</td>
</tr>
</table>
</form>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
$(function(){
$("td").click(function(){
eqnum = $(this).parent("tr:first").find("td").index($(this));
html = $(this).parent("tr:first").siblings("tr").find("td").eq(eqnum).html();
alert(html);
})
})
$("td").click(function(){
eqnum = $(this).parent("tr:first").find("td").index($(this));
html = $(this).parent("tr:first").siblings("tr").find("td").eq(eqnum).html();
alert(html);
})
})
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询