如何使HTML表格单元格可编辑? [英] How to make HTML table cell editable?

查看:846
本文介绍了如何使HTML表格单元格可编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让html表的某些单元格可编辑,只需双击一个单元格,输入一些文本并将更改发送到服务器即可。我不想使用像dojo数据网格这样的工具包。因为它提供了一些其他功能。你会提供一些代码片段或建议如何实现它吗?

行或表问题。



针对IE8兼容性进行更新
$ b

 <表> 
< tr>< td>< div contenteditable>我是可编辑的< / div>< / td>< td>< div contenteditable>我也是可编辑的< / div>< / TD>< / TR>
< tr>< td>我不可编辑< / td>< / tr>
< / table>

请注意,如果您让表格可编辑,至少在Mozilla中,您可以删除行等。

您还需要检查目标受众的浏览器是否支持此属性。



至于听取更改(以便您可以发送到服务器),请参阅 contenteditable change events


I'd like to make some cells of html table editable, simply double click a cell, input some text and the changes can be sent to server. I don't want to use some toolkits like dojo data grid. Because it provides some other features. Would you provide me some code snippet or advices on how to implement it?

解决方案

You can use the contenteditable attribute on the cells, rows, or table in question.

Updated for IE8 compatibility

<table>
<tr><td><div contenteditable>I'm editable</div></td><td><div contenteditable>I'm also editable</div></td></tr>
<tr><td>I'm not editable</td></tr>
</table>

Just note that if you make the table editable, in Mozilla at least, you can delete rows, etc.

You'd also need to check whether your target audience's browsers supported this attribute.

As far as listening for the changes (so you can send to the server), see contenteditable change events

这篇关于如何使HTML表格单元格可编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆