<%@ 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. pip 在windows下的更新升级

    1. pip 在 PyCharm 无法自动更新 2.   https://pip.pypa.io/en/latest/installing.html 官方网页要求在 cmd中输入以下命令进行 pip的 ...

  2. window10 下 php7.0 添加Sqlserver扩展

    第一步.7.0.x 7.0.x的扩展下载地址: Microsoft Drivers for PHP for SQL Server  https://www.microsoft.com/en-us/do ...

  3. mysql 查找除id外其他重复的字段数据

    如表 test1 有多个重复的字段 其中有些数据完全重复是错误的数据,我们要把他找出来,然后删除掉 select * from test1 a where (a.phone,a.name) in ( ...

  4. 船长带你看书——《selenium2 python 自动化测试实战》(1)

    有很多selenium的教程,你没有从头看,当你看的时候已经很难跟上作者的节奏了.现在,你有机会再从头学一次了.从今天开始,船长会从最基本的知识开始,和大家一起学selenium.能不能跟着一起就看大 ...

  5. PHP的网站主要攻击方式有哪些

    1.命令注入(Command Injection) 2.eval注入(Eval Injection) 3.客户端脚本攻击(Script Insertion) 4.跨网站脚本攻击(Cross Site ...

  6. apiman 安装&&使用

    安装测试基于docker 1. docker  image pull   docker pull apiman/on-wildfly1   2. 启动   docker run -d -p 8081: ...

  7. Spring整合Quartz定时器

    1.添加jar #此处省略spring核心jar包 <dependency> <groupId>org.quartz-scheduler</groupId> < ...

  8. for, while的用法

    for循环求1+2+3+4+....+100 # include <stdio.h> int main(void) { int i; //循环中更新的变量i不能定义成浮点型 ; ; i&l ...

  9. jeecg中service中注入jdbc的注解

    @Resource private JdbcTemplate jdbcTemplate;

  10. Unit06: 外部对象概述 、 window 对象 、 document 对象

    Unit06: 外部对象概述 . window 对象 . document 对象 小代码演示: <!DOCTYPE html> <html> <head> < ...