使用DOM在TD中插入DIV [英] Using DOM to insert a DIV within a TD

查看:68
本文介绍了使用DOM在TD中插入DIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我在新添加的行中动态创建一个DIV到之前创建的表。我坚持正确的语法。以下是我目前的努力:

Hi all,

I am dynamically creating a DIV within a newly added row to a previously created table. I''m stuck with the correct syntax. Below is my current effort:

展开 | 选择 | Wrap | 行号

推荐答案

第5行和第7行的insertDiv应该是insertdiv(您应该使用其他名称以避免混淆)。将第2行移动到您想要创建div的位置(除非您对innerHTML感到满意)。
insertDiv on lines 5 and 7 should be insertdiv (you should probably use another name to avoid confusion). Move line 2 to where you want to create the div (unless you''re happy with innerHTML).


感谢您的回复,但我仍然卡住了。我基本上试图将细胞插入现有的表中,并将它们放在DIV中,以便以后可以轻松删除这些新细胞。下面是更简洁的代码,它应该向已经有单元格的表中添加一行2个单元格,并将新单元格保留在单个DIV中:

Thanks for the reply but I''m still stuck. I''m basically trying to insert cells into an existing table, and place them within a DIV so these new cells can be easily removed later. Below is more succinct code which is supposed to add a row of 2 cells to a table that already has cells, and keep the new cells within a single DIV:

展开 | 选择 | Wrap | 行号


不能将单元格放在DIV中,如果你想稍后快速删除它们,请删除该行。在代码中,我看不到你创建的DIV的任何用法。
You cannot place cells inside a DIV, if you want to quickly remove them later, remove the row. Plus in the code, I can''t see any usage of the DIV you created.


这篇关于使用DOM在TD中插入DIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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