<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>点击</title>
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="author" content="linjiqin218@126.com" />
<meta name="Copyright" content="parami|厦门波罗密网络科技有限公司" /> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<jsp:include page="/demo/base/js_bootstrap.jsp" />
<script type="text/javascript">
$(function(){
//用jQuery获取table中td值
$("#mytable td").click(function(){
alert("table td值:"+$(this).text());
}); //jQuery获取table中点击位置所在行的id
$("#mytable td").click(function() {
//td的id
alert($(this).attr("id"));
//tr的id
alert($(this).parent().attr("id"));
});
});
</script>
</head>
<body>
<table id="mytable" width="708px;" cellpadding="5" cellspacing="1">
<tbody>
<tr bgcolor="#DEE9F4" id="tr_1">
<td align="center"> 日</td>
<td align="center"> 一 </td>
<td align="center"> 二 </td>
<td align="center"> 三 </td>
<td align="center"> 四 </td>
<td align="center"> 五 </td>
<td align="center"> 六 </td>
</tr>
<tr bgcolor="#DEE9F4" id="tr_2">
<td align="center"> &nbsp; </td>
<td align="center"> &nbsp; </td>
<td align="center"> &nbsp; </td>
<td align="center"> 1 </td>
<td align="center"> 2 </td>
<td align="center"> 3 </td>
<td align="center"> 4</td>
</tr>
<tr bgcolor="#DEE9F4" id="tr_3">
<td align="center"> 5 </td>
<td align="center"> 6 </td>
<td align="center"> 7 </td>
<td align="center"> 8 </td>
<td align="center"> 9 </td>
<td align="center" bgcolor="red">10</td>
<td align="center">11</td>
</tr>
<tr bgcolor="#DEE9F4" id="tr_4">
<td align="center"> 12 </td>
<td align="center"> 13 </td>
<td align="center"> 14 </td>
<td align="center"> 15 </td>
<td align="center"> 16 </td>
<td align="center"> 17 </td>
<td align="center"> 18 </td>
</tr>
</tbody>
</table>
</body>
</html>

如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】。
如果,您希望更容易地发现我的新博客,不妨点击一下左下角的【关注我】。
如果,您对我的博客所讲述的内容有兴趣,请继续关注我的后续博客,我是【Ruthless】。

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

用jQuery获取table中行id和td值的更多相关文章

  1. jQuery获取table表中的td标签

    首先我来介绍一下我遇到的问题 1.当有一个table表包含了<tr>标签,<td>标签,大致可以认为是这样的: <tr> <td> @scene.ID ...

  2. jQuery遍历table中的tr td并获取td中的值

    jQuery遍历table中的tr td并获取td中的值 $(function(){ $("#tableId tr").find("td").each(func ...

  3. jquery】常用的jquery获取表单对象的属性与值

    [jquery]常用的jquery获取表单对象的属性与值 1.JQuery的概念 JQuery是一个JavaScript的类库,这个类库集合了很多功能方法,利用类库你可以用一些简单的代码实现一些复杂的 ...

  4. JQuery获取与设置HTML元素的值value

    JQuery获取与设置HTML元素的值value 作者:简明现代魔法图书馆 发布时间:2011-07-07 10:16:13 20481 次阅读 服务器君一共花费了13.221 ms进行了6次数据库查 ...

  5. js&jquery 获取select下拉框的值、文本内容、自定义属性

      js&jquery 获取select下拉框的值.文本内容.自定义属性 CreationTime--2018年7月2日09点22分 Author:Marydon html <selec ...

  6. Jquery获取select option动态添加自定义属性值失效

    Jquery获取select option动态添加自定义属性值失效 2014/12/31 11:49:19 中国学网转载 编辑:李强 http://www.xue163.com/588880/3909 ...

  7. Jquery获取select选中的文本与值

    jquery获取select选择的文本与值获取select :获取select 选中的 text :    $("#ddlregtype").find("option:s ...

  8. jquery获取select选择的文本与值

    jquery获取select选择的文本与值获取select :获取select 选中的 text :    $("#ddlregtype").find("option:s ...

  9. jquery获取table,遍历输出tr中各个td的内容(转载)

    首先,依赖jquery.. 1 $('#btntb').click(function(){ 2 $('#tab tr').each(function(i){ // 遍历 tr 3 $(this).ch ...

随机推荐

  1. CMDB

    一.CMDB CMDB --Configuration Management Database 配置管理数据库, CMDB存储与管理企业IT架构中设备的各种配置信息,它与所有服务支持和服务交付流程都紧 ...

  2. Sprint第一个冲刺(第三天)

    一.Sprint介绍 今天我们完成了简单登录界面及美化的任务,完成了此次整个Sprint的百分之十五. 下面是实验截图: 二.Sprint周期 看板: 燃尽图:

  3. Gridview中实现求和统计功能

    GridView加入自动求和求平均值小计 效果图: 解决方案: private double sum = 0; //取指定列的数据和,你要根据具体情况对待可能你要处理的是int protected v ...

  4. hadoop之 hadoop用途方向

    hadoop是什么?Hadoop是一个开源的框架,可编写和运行分不是应用处理大规模数据,是专为离线和大规模数据分析而设计的,并不适合那种对几个记录随机读写的在线事务处理模式.Hadoop=HDFS(文 ...

  5. Debian初识(选择最佳镜像发布站点加入source.list文件)

    选择最佳镜像发布站点加入source.list文件:netselect,netselect-apt “该将哪个Debian镜像发布站点加入source.list文件?”.有很多方法来选择镜像发布站点, ...

  6. 浅谈splay

    \(BST\) 二叉查找树,首先它是一颗二叉树,其次它里面每个点都满足以该点左儿子为根的子树里结点的值都小于自己的值,以该点右儿子为根的子树里结点的值都大于自己的值.如果不进行修改,每次查询都是\(O ...

  7. bzoj1503[NOI2004]郁闷的出纳员——Splay

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1503 好奇怪呀!为什么而TLE? 各种修改终于卡时过了.可是大家比我快多了呀?难道是因为自己 ...

  8. 选择排序算法-python实现

    #-*- coding: UTF-8 -*- import numpy as np def SelectSort(a): for i in xrange(0,a.size): min = a[i] p ...

  9. 微信卡券开发,代金券修改卡券信息返回40145错误码: invalid update! Can not both set PayCell and CenterCellInfo(include: center_title, center_sub_title, center_url). hint: [DZ9rna0637ent1]

      修改代金券,接口返回的数组是这样的内容 Array ( [errcode] => 40145 [errmsg] => invalid update! Can not both set  ...

  10. Jenkins的pipeline

    说明 再官网文档上有说明pipeline的工作流程,具体可以参考pipeline文档和语法文档. 这里将pipeline的生命周期图贴出来  我们暂时不会用到完整的流程,只摘取有用的部分,完成最小的流 ...