Change Javascript function to edit cells instead of append them

Sorry for the vagueness of my question. Let me start from scratch. I currently have this: http://jsfiddle.net/kmg4x/1/ and this other question I posted is related: https://stackoverflow.com/questions/5250728/alternative-to-jeditable-for-editable-table-cells Although I eventually want to do away with the form on the top and make the cells editable, this question is primarily about changing the table contents as opposed to adding new cells. As you can see, if you enter a single letter into the top left input box and click out, it appends the table with the remaining part of the array (after a `slice`). I would like instead for it to change the contents of the existing cells. I have tried changing `cell.appendChild(document.createTextNode` to `innerHTML` but it ended up doing the exact same thing. My guess is that it has to do with changing the `var tbody = document.getElementById(id).getElementsByTagName("tbody")[0];` to `var tbody = document.getElementById(id).getElementsByTagName("td")[0];` but when i do that it just breaks. Is there an `editCell()` equivalent of `tbody.insertRow(r)` Maybe `td.innerHTML(r)`? Eventually I will add a button that can add and remove rows. Hope this is better.

以上就是Change Javascript function to edit cells instead of append them的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏