在 jQuery 中编辑行和动态 id 问题?
该表处于循环中。也就是说行数是动态的。
<tr id="data">
<td><input name="cb" type="checkbox" value="val"></td>
<td>var 1</td>
<td>var 2</td>
<td>var 3</td>
</tr>
一个编辑按钮:
<input type="submit" value="edit" id="edit">
每一行都有一个复选框。单击该复选框后,整行应处于编辑模式。我尝试了很多方法,但离结果还很远。我遇到的第二个问题是 id 问题。因为行是动态的所以......
This table is in the loop. That is number of rows is dynamic.
<tr id="data">
<td><input name="cb" type="checkbox" value="val"></td>
<td>var 1</td>
<td>var 2</td>
<td>var 3</td>
</tr>
One edit button:
<input type="submit" value="edit" id="edit">
Each row has a checkbox. On click of the checkbox the entire row should be in the edit mode. I tried a lot of ways but still far away from the result. The second issue I faced is the id issue. Because the rows are dynamic so...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
可能您正在寻找的是这个,它使用一个名为“contentEditable”属性的东西,该属性可以编辑 HTML 文档:
http://valums.com/edit-in-place/
可以在此处找到更多信息:http://msdn.microsoft.com/en-us/library/ms537837%28v=vs.85%29.aspx
Probably what you are looking for is this, it uses a thing called "contentEditable" property, which enables editing HTML documents:
http://valums.com/edit-in-place/
More info can be found here: http://msdn.microsoft.com/en-us/library/ms537837%28v=vs.85%29.aspx
你说
但您也有
id
值 必须在文档中是唯一的,因此您必须对其进行修改以不使用id
。但您不需要每行都有
id
。您可以这样做:实例
You say
but you also have
id
values must be unique within the document, so you'll have to modify that to not useid
s.But you don't need an
id
on each row. You can do this:Live example