如何从javascript中的表中删除一行 [英] how to remove a row from table in javascript

查看:84
本文介绍了如何从javascript中的表中删除一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...

我有桌子.我动态添加行,每行中都有一个按钮.
单击按钮后,特定行将被删除,
我尝试但动态添加的值始终显示表长度1,因此我无法删除该行...

hi to all...

i ve table. i add row dynamically, i ve button in each row.
once i click the button the particular row will be delete,
i try but the value added dynamically its alway show the table length 1, so i cant delete the row...

推荐答案

如果使用jQuery,这很容易:

It''s easy if you use jQuery:


(您的按钮).closest(' tr').删除();
(yourbutton).closest('tr').remove();



如果在所有删除按钮上添加"btnRemoveRow"类:



If you add a class "btnRemoveRow" on all your delete-buttons:


(文档).ready(功能(){
(document).ready(function() {


这篇关于如何从javascript中的表中删除一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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