javascript - 将表格行复制到另一个表格 HTML

标签 javascript html html-table

Fiddle

我有两张 table 。当我点击一个表格行时,它会复制到另一个表格,我会根据我的要求更改按钮。请帮我。

$(window).load(function() {
                var items = [];

                $(".addBtn").on("click", function() {
                    var newTr = $(this).closest("tr").clone();

                    var newButtonHTML = "<input type = 'button' value='Edit' onclick='Edit()' /><input type='button' value='Delete' onclick='deleteRow(this.parentNode.parentNode.rowIndex)'/>";
                    $(newButtonHTML).children("button").click(function(e) {
                    });

                    $(newTr).children("td:last").html("").html(newButtonHTML);
                    items.push(newTr);
                    newTr.appendTo($("#stopsTable"));

                });

最佳答案

在你的例子中,它是一个错误的选择器

$('#myTable.tr') 

代替

$('#myTable tr')

检查固定版本:http://jsfiddle.net/V7wXD/7/

最好的问候!

关于javascript - 将表格行复制到另一个表格 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23757096/

相关文章:

javascript - HTML select 中所选项目发生更改时如何处理事件

javascript - 如何添加这个滚动功能?

html - 从多个子类别访问菜单

javascript - 如何用html表格制作游戏?

css - AngularJS 动画交换表中的行

javascript - 将变量传递给回调函数

javascript - 在函数范围内关闭 console.log

html - 模板文件的变化,Magento

jquery - 将来自输入的所有数据价格与 jquery 中可用的属性相加

html - 如何垂直对齐 td 和 span 中的文本?