简体   繁体   中英

trying to add rows and cells to a table dynamically

I have been successful in adding rows and cells to a table when the content of each cell is a text input. But when I try to add custom text (or a hyperlink) I do not get any result. Here is my code:

if (bb == "link") {

            var newRow = $("<tr></tr>").appendTo(thisTable);

            var newLinkCell = $("<td></td>").appendTo(newRow);

            var hInput = $("<span>" + l + "</span>").appendTo(newLinkCell);

        }

UPDATED FIDDLE:

This is the relevant code. A fiddle of the entire problem is here: http://jsfiddle.net/N8sW2/1/

My problem deals with the "Link to Page" button. Please help.

var thisTable = $(this).siblings("table");

此行将找不到任何元素,因为您的添加按钮没有表的兄弟姐妹。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM