js怎么清空tr


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<TITLE> New Document </TITLE>

<META NAME="Generator" CONTENT="EditPlus">

<META NAME="Author" CONTENT="">

<META NAME="Keywords" CONTENT="">

<META NAME="Description" CONTENT="">

<script language="javascript">// Example: obj = findObj("image1");

function findObj(theObj, theDoc)

{

var p, i, foundObj;

if(!theDoc) theDoc = document;

if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)

{  theDoc = parent.frames[theObj.substring(p+1)].document;  theObj = theObj.substring(0,p); } if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj]; for (i=0; !foundObj && i < theDoc.forms.length; i++)   foundObj = theDoc.forms[i][theObj]; for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)   foundObj = findObj(theObj,theDoc.layers[i].document); if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);  return foundObj;

}

 

//删除指定行

function DeleteSignRow(rowid){

var signFrame = findObj("SignFrame",document);

var signItem = findObj(rowid,document);

alert(rowid);

//获取将要删除的行的Index

var rowIndex = signItem.rowIndex;

   

//删除指定Index的行

signFrame.deleteRow(rowIndex);

   

//重新排列序号,如果没有序号,这一步省略

for(i=rowIndex;i<signFrame.rows.length;i++){

signFrame.rows[i].cells[0].innerHTML = i.toString();

}

}

//清空列表

function ClearAllSign(){

if(confirm('确定要清空所有参与人吗?')){

var signFrame = findObj("SignFrame",document);

var rowscount = signFrame.rows.length;

   

//循环删除行,从最后一行往前删除

for(i=rowscount - 1;i > 0; i--){

  signFrame.deleteRow(i);

}

   

//重置最后行号为1

var txtTRLastIndex = findObj("txtTRLastIndex",document);

txtTRLastIndex.value = "1";

   

 

}

}

</script>

</HEAD>

   

<BODY>

<div>

<table width="613" border="0" cellpadding="2" cellspacing="1" id="SignFrame">

       <tr id="trHeader">

        <td width="27" bgcolor="#96E0E2">序号</td>

        <td width="64" bgcolor="#96E0E2">用户姓名</td>

        <td width="98" bgcolor="#96E0E2">电子邮箱</td>

        <td width="92" bgcolor="#96E0E2">固定电话</td>

        <td width="86" bgcolor="#96E0E2">移动手机</td>

        <td width="153" bgcolor="#96E0E2">公司名称</td>

        <td width="57" align="center" bgcolor="#96E0E2"> </td>

       </tr>

    </table>

  </div>

  <div>

    <input type="button" name="Submit" value="添加参与人" onclick="AddSignRow()" />

   <input type="button" name="Submit2" value="清空" onclick="ClearAllSign()" />

   <input name='txtTRLastIndex' type='hidden' id='txtTRLastIndex' value="1" />

  </div>

   

</BODY>

</HTML>

以上就是js怎么清空tr的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

vue 的 render 方法中 h 是什么?

javascript的重构技巧

js 移动端的 touch 事件使用

js如何将json字符串转换为json对象

利用html+css+js实现简单的点赞效果

利用js实现图片的轮播效果

怎么体现js继承关系

js如何实现利用键盘控制div移动

javascript中init方法怎么用

jquery 过时了吗?

更多相关阅读请进入《js》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...