本文转自:http://www.xinotes.org/notes/note/1087/

<!DOCTYPE html>
<html>
<head>
<title>jQuery Table</title>

<style type="text/css">
body {
font-family: sans-serif;
}

table {
border-collapse: collapse;
margin-bottom: 5px;
}

td {
padding: 4px;
border: #4488aa 1px solid;
}

input {
text-align: right;
padding: 2px;
width: 20px;
}
</style>

<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
</script>

<script type="text/javascript">
$(function() {
$('td').click(function() {
var tr = $(this).parent();
for (var i = 0; i < tr.children().length; i++) {
if (tr.children().get(i) == this) {
var column = i;
break;
}
}

var tbody = tr.parent();
for (var j = 0; j < tbody.children().length; j++) {
if (tbody.children().get(j) == tr.get(0)) {
var row = j;
break;
}
}
$('span').text(row + ', ' + column);
});
});
</script>
</head>

<body>
<h1>Table Cell Value</h1>
<table>
<tr><td>Cell 1-1</td><td>Cell 1-2</td><td>Cell 1-3</td></tr>
<tr><td>Cell 2-1</td><td>Cell 2-2</td><td>Cell 2-3</td></tr>
<tr><td>Cell 3-1</td><td>Cell 3-2</td><td>Cell 3-3</td></tr>
</table>

You clicked cell: <span>None</span>
</body>
</html>

本文转自:http://www.jquery4u.com/snippets/jquery-remove-table-column-by-column-number/

Simple jQuery code snippet to remove an entire table column based on the column number. It also removes the table row heading associated with the removed column.

//remove the 1st column
$('#table').find('td,th').first().remove();
//remove the 1st column
$('table tr').find('td:eq(1),th:eq(1)').remove();
//remove the 2nd column
$('table tr').find('td:eq(1),th:eq(1)').remove();
//remove the nth column
$('table tr').find('td:eq(n),th:eq(n)').remove();

[转]jQuery: get table column/row index remove table column (by column number)的更多相关文章

  1. jQuery EasyUI, datagrid, treegrid formatter 参数比较 row index

    如题: datagrid中,见官方文档: formatter function The cell formatter function, take three parameter:value: the ...

  2. [20180317]12c TABLE ACCESS BY INDEX ROWID BATCHED3.txt

    [20180317]12c TABLE ACCESS BY INDEX ROWID BATCHED3.txt --//简单探究12c TABLE ACCESS BY INDEX ROWID BATCH ...

  3. [20180317]12c TABLE ACCESS BY INDEX ROWID BATCHED.txt

    [20180317]12c TABLE ACCESS BY INDEX ROWID BATCHED.txt --//简单探究12c TABLE ACCESS BY INDEX ROWID BATCHE ...

  4. mysql 添加索引,ALTER TABLE和CREATE INDEX的区别

    nvicat-->mysql表设计-->创建索引. (1)使用ALTER TABLE语句创建索引,其中包括普通索引.UNIQUE索引和PRIMARY KEY索引3种创建索引的格式: PRI ...

  5. Replication-Replication Distribution Subsystem: agent xxxxxx failed. Column names in each table must be unique

    最近遇到一个关于发布订阅(Replication)的奇葩问题,特此记录一下这个案例.我们一SQL SERVER数据库服务器出现大量告警.告警信息如下所示: DESCRIPTION: Replicati ...

  6. Mysql运行SQL文件 错误Incorrect table definition;there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

    问题描述 想从服务器上DOWN下数据库.操作:先把数据库转存为SQL文件,然后在本地利用navicate运行SQL文件,出现错误信息: Incorrect table definition;there ...

  7. Error Code: 1175.You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.

    在MySQL Workbench里面使用SQL语句: delete from 表名 提示出错: Error Code: 1175.You are using safe update mode and ...

  8. [转载]jquery获取元素索引值index()方法:

    jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...

  9. jquery获取元素索引值index()方法

    jquery的index()方法 搜索匹配的元素,并返回相应元素的索引值,从0开始计数. 如果不给 .index() 方法传递参数,那么返回值就是这个jQuery对象集合中第一个元素相对于其同辈元素的 ...

随机推荐

  1. Picasso VS Glide

    原文: Introduction to Glide, Image Loader Library for Android, recommended by Google 在泰国举行的谷歌开发者论坛上,谷歌 ...

  2. java Linkedhashmap源码分析

    LinkedHashMap类似于HashMap,但是迭代遍历它时,取得“键值对”的顺序是插入次序,或者是最近最少使用(LRU)的次序.只比HashMap慢一点:而在迭代访问时反而更快,因为它使用链表维 ...

  3. linux 进程间通信机制(IPC机制)一总览

    1.作用:进程间通信机制(Inter Process Communication,IPC),这些IPC机制的存在使UNIX在进程通信领域手段相当丰富,也使得程序员在开发一个由多个进程协作的任务组成的系 ...

  4. symbol访问法及symbor注册表

    symbol主要作用是防止对象属性名冲突 在ES6之前,对象的属性名只能是字符串,这样很容易造成字符串的冲突. 例:假设person对象是从外部库引入的一个对象 let person = { name ...

  5. [LeetCode] 92. Reverse Linked List II_Medium tag: Linked List

    Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Exa ...

  6. android: 获取屏幕高度和虚拟导航栏高度的几种方法

    package com.yongdaimi.android.androidapitest; import android.app.Activity; import android.content.Co ...

  7. [Django笔记] 从已有的数据库构建应用

    Django适合从零开始构建,所谓 'Green-field' 开发.那么当我需要基于已存在的数据库构建应用时怎么办呢? inspectdb # 扫描默认数据库 python manage.py in ...

  8. 【bzoj2190】: [SDOI2008]仪仗队 数论-欧拉函数

    [bzoj2190]: [SDOI2008]仪仗队 在第i行当且仅当gcd(i,j)=1 可以被看到 欧拉函数求和 没了 /* http://www.cnblogs.com/karl07/ */ #i ...

  9. flink学习笔记-各种Time

    说明:本文为<Flink大数据项目实战>学习笔记,想通过视频系统学习Flink这个最火爆的大数据计算框架的同学,推荐学习课程: Flink大数据项目实战:http://t.cn/EJtKh ...

  10. linux read和write

    int write(int fd, const void *buf, size_t count); 如果是堵塞fd,则返回值是count,或者是0,-1: 如果是非堵塞fd,则返回值是写入的字节数,或 ...