很简单
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style>
table {
border-collapse: collapse;
border-spacing: 0;
margin-right: auto;
margin-left: auto;
width: 100%;
}
th,td {
border: 1px solid #b5d6e6;
font-size: 12px;
font-weight: normal;
vertical-align: middle;
height: 20px;
width: 25%;
}
th {
text-align: center;
background-color: Gray;
}
</style>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/jquery-3.2.1.min.js"></script>
<script>
$(function() {
$('#tableId').on('dblclick', 'td', function() {
//console.info($(this).text());
var oldVal = $(this).text();
var input = "<input type='text' id='tmpId' value='" + oldVal + "' >";
$(this).text('');
$(this).append(input);
$('#tmpId').focus();
$('#tmpId').blur(function() {
if ($(this).val() != '') {
oldVal = $(this).val();
}
//closest:是从当前元素开始,沿Dom树向上遍历直到找到已应用选择器的一个匹配为止。
$(this).closest('td').text(oldVal);
});
});
});
</script>
</head>
<body>
<table id="tableId">
<tr><th>head01</th><th>head02</th><th>head03</th><th>head04</th></tr>
<tr><td>head11</td><td>head12</td><td>head13</td><td>head14</td></tr>
<tr><td>head21</td><td>head22</td><td>head23</td><td>head24</td></tr>
<tr><td>head31</td><td>head32</td><td>head33</td><td>head34</td></tr>
<tr><td>head41</td><td>head42</td><td>head43</td><td>head44</td></tr>
</table>
</body>
</html>
网友回复
如何编写一个chrome插件实现多线程高速下载大文件?
cdn版本的vue在网页中出现typeerror错误无法找到错误代码位置怎么办?
pywebview能否使用webrtc远程控制共享桌面和摄像头?
pywebview6.0如何让窗体接受拖拽文件获取真实的文件路径?
如何在linux系统中同时能安装运行apk的安卓应用?
python有没有离线验证码识别ocr库?
各家的ai图生视频及文生视频的api价格谁最便宜?
openai、gemini、qwen3-vl、Doubao-Seed-1.6在ui截图视觉定位这款哪家更强更准?
如何在linux上创建一个沙箱隔离的目录让python使用?
pywebview如何使用浏览器自带语音识别与webspeech 的api?