jQuery table td可编辑
参考链接:
http://www.freejs.net/
http://www.freejs.net/article_biaodan_34.html
http://www.freejs.net/search.php?keywords=%E7%BC%96%E8%BE%91
效果图:
源代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>jQuery table td可编辑</title>
<style type="text/css">
/*
* page css
*/
a,body,center,code,dd,div,dl,dt,em,fieldset,form,h1,h2,h3,h4,h5,h6,html,i,img,label,li,ol,p,pre,small,span,strong,sub,sup,u,ul {
margin: auto;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: 0 0
} h2 {
text-align: center;
padding: 10px;
font-size: 20px
} a {
color: #007bc4;
text-decoration: none
} a:hover {
text-decoration: underline
} ol,ul {
list-style: none
} table {
border-collapse: collapse;
border-spacing: 0
} body {
height: 100%;
font: 12px;
color: #51555C;
background: #2C2C2C
} img {
border: none
} .logo {
width: 910px
} #main_demo {
width: 910px;
min-height: 600px;
margin: 30px auto 0 auto;
background: #fff;
-moz-border-radius: 12px;
-khtml-border-radius: 12px;
-webkit-border-radius: 12px;
border-radius: 12px
} .ad {
text-align: center;
margin-top: 25px
} .clear {
clear: both
} /*
* demo styles
*/
table {
margin: 0 auto;
border-collapse: collapse
} td,th {
width: 10%;
font-size: 14px;
padding: 10px 0;
text-align: center;
border: 1px solid #ddd
} th {
background-color: #f4f4f4
} /*
* input
*/
td.input {
position: relative
} td input {
width: 100%;
border: 1px solid #CF5C74;
background: #F90;
border-radius: 4px;
display: block;
position: absolute;
text-align: center;
font-size: 14px;
left: 0;
top: 0;
padding: 11px 0;
margin: -1px 0 0 -1px
} td.hover {
background: #eee
}
</style>
</head>
<body>
<div id="main_demo">
<h2>jQuery table td可编辑</h2>
<table border="0" cellpadding="0" cellspacing="0" width="500">
<tbody>
<tr>
<th>td input演示</a></th>
<th scope="col">列1</th>
<th scope="col">第二列</th>
<th scope="col">其他</th>
</tr>
</tbody>
<tbody>
<tr>
<th>1</th>
<td class="content"></td>
<td class="text"></td>
<td class="position">0</td>
</tr>
<tr>
<th>2</th>
<td class="content"></td>
<td class="text">0</td>
<td class="position">0</td>
</tr>
<tr>
<th>3</th>
<td class="content"></td>
<td class="text"></td>
<td class="position hover">0</td>
</tr>
</tbody>
</table>
</div> <!-- JS文件:jQuery-百度CDN -->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('table td').click(function() {
if (!$(this).is('.input')) {
$(this).addClass('input').html('<input type="text" value="' + $(this).text() + '" />')
.find('input')
.focus()
.blur(function() {
$(this).parent().removeClass('input').html($(this).val() || 0);
});
}
}).hover(function() {
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
});
</script>
</body>
</html>
^_^
jQuery table td可编辑的更多相关文章
- 可编辑的表格:jQuery+PHP实现实时编辑表格字段内容
在本例中,我们会通过jQuery实现单击将一个文本信息变为可编辑的表单,你可以对文本内容进行编辑,然后点击“确定”按钮,新的内容将发送到后台PHP程序处理,并保存到数据库:当点击“取消”按钮,则页面恢 ...
- [Web 前端] Jquery实现可直接编辑的表格
cp from :https://www.cnblogs.com/sjqq/p/6392001.html?utm_source=itdadao&utm_medium=referral 文实例讲 ...
- JQuery实现可直接编辑的表格
本文实例讲述了JQuery实现可直接编辑的表格.分享给大家供大家参考.具体分析如下: 功能: 创建一个表格,用户单击某个单元格后,可以直接修改单元格文本.在编辑状态下,用户可按回车键确认修改,按ESC ...
- Jquery easyui开启行编辑模式增删改操作
Jquery easyui开启行编辑模式增删改操作 Jquery easyui开启行编辑模式增删改操作先上图 Html代码: <table id="dd"> </ ...
- [转]Jquery easyui开启行编辑模式增删改操作
本文转自:http://www.cnblogs.com/nyzhai/archive/2013/05/14/3077152.html Jquery easyui开启行编辑模式增删改操作先上图 Html ...
- 点击编辑table变为可编辑状态
简单描述:开发中遇到一个小困难,table展示的数据,需要是可编辑的,点击编辑按钮,页面table可以进行编辑,编辑完成后,点击保存数据就保留下来~~~ 思路:用一个带有input的表去替换不带inp ...
- Jquery改变td内容为1的颜色
Jquery改变td内容为1的颜色<table id="tb" > <tr> <td val="1">1</td> ...
- UIWebView中加载HTML的Table,td设置百分比宽度并且宽度不被里面的内容撑开
正常情况下,iOS使用WebView加载HTML的Table时,为了让Table适应屏幕宽度,会使用百分比设置td的宽度,但是由于td中的内容过多,td会被撑开,导致整个Table的宽度会变宽,超出屏 ...
- [Js/Jquery]table行转列
摘要 在使用ews调用exhange的收件箱的并在h5页面显示邮件详情的时候,因为返回的每封邮件的内容都是htmlbody,没有textbody.每封邮件又没什么规律,用正则表达式来匹配内容并不合适, ...
随机推荐
- System.in的用法
方法1 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));Scanner scanner=new Sca ...
- 记一次金士顿DT100 G3 32G修复
修复方法参考原文:http://bbs.mydigit.cn/read.php?tid=2291146 故障描述:某天在使用时突然要求格式化,但里面有重要数据,于是想通过DG恢复出来,没想到经过这样的 ...
- eth0 eth0:1 eth0.1 的区别
eth0 eth0:1 和eth0.1三者的关系对应于物理网卡.子网卡.虚拟VLAN网卡的关系:物理网卡:物理网卡这里指的是服务器上实际的网络接口设备,这里我服务器上双网卡,在系统中看到的2个物理网卡 ...
- 2017 码云最火爆开源项目 TOP 50,你都用过哪些
本文转自:https://share.html5.qq.com/fx/u?r=JdjvzwC 2017 年度码云热门项目排行榜 TOP 50 出炉啦!我们根据所有开源项目在码云的用户关注度.活跃度.访 ...
- 使用textutil进行文件格式转换
Typorahtml, body {overflow-x: initial !important;}.CodeMirror { height: auto; } .CodeMirror-scroll { ...
- Py2.7 no module named tkinter
一个简单的例子 #! /usr/bin/env python#coding=utf-8from tkinter import *Label(text="Spam").pack()m ...
- ubuntu 安装 sshd
ubuntu 上可以安装 SSHD 服务,方便远程操作. sudo apt-get update sudo apt-get install openssh-server sudo /etc/init. ...
- 关于C3P0容错和自动重连特性的研究
转载: http://blog.csdn.net/cutesource/article/details/5422093 最近常有数据库和网络设备升级和搬迁等事情,而各个应用都是基于数据库连接池做的,大 ...
- USB入门
简述 USB(Universal Serial Bus)全称通用串口总线,USB为解决即插即用需求而诞生,支持热插拔.USB协议版本有USB1.0.USB1.1.USB2.0.USB3.1等,USB2 ...
- ashx session 赋值 获取
ashx想获取session值 需要继承 IRequiresSessionState接口 ExcelHelper : IHttpHandler, IRequiresSessionState publi ...