1
我在某些onclick函数中有一个任务。我有一个表,其中每列包含一个下拉列表或文本框。其中一列包含一个按钮。如果我用dropdownlist单击该按钮的行,包含添加按钮的文本框必须动态添加为下一行。我可以这样做吗?哪个更好的JavaScript或jQuery ..plz帮助我..在javascript中使用onclick函数动态添加行
我在某些onclick函数中有一个任务。我有一个表,其中每列包含一个下拉列表或文本框。其中一列包含一个按钮。如果我用dropdownlist单击该按钮的行,包含添加按钮的文本框必须动态添加为下一行。我可以这样做吗?哪个更好的JavaScript或jQuery ..plz帮助我..在javascript中使用onclick函数动态添加行
你可以尝试以下
在该行的onclick添加的功能
function cloneRow(event){
var tar_ele;
if ($.browser.msie) {
// IE takes SRCELEMENT for event source.
// may the force shred IE.
tar_ele = $(event.srcElement);
} else {
tar_ele = $(event.target);
}
// Now take the parent of the clicked item as the item is a button in a row
var row = tar_ele.parent();
// Now clone the row and add it to the parent.
row.clone().appendTo(row.parent());
}
希望这有助于。
你可以试试这个:
$('button-id').click(function() {
$('container-id').after('<input /><select />');
});
类似的东西,将你添加的输入和选择框新的一行到容器或你的表的末尾。