易截截图软件、单文件、免安装、纯绿色、仅160KB

使用javascript动态添加和删除table的行和列

第一种方法:使用insertRow添加行,使用insertCell添加单元格,再用innerHTML填充单元格。使用deleteRow删除行,代码如下:
Javascript代码:
function addRow()
  {
     var root = document.getElementById("tbody")
     var allRows = root.getElementsByTagName('tr');
     var allCells = allRows[0].getElementsByTagName('td');
     var newRow = root.insertRow();
     var newCell0 = newRow.insertCell();
     var newCell1 = newRow.insertCell();
     var newCell2 = newRow.insertCell();
     var newCell3 = newRow.insertCell();
     newCell0.innerHTML = allCells[0].innerHTML;
     newCell1.innerHTML = allCells[1].innerHTML;
     newCell2.innerHTML = allCells[2].innerHTML;
     newCell3.innerHTML = allCells[3].innerHTML;
  }
  function removeRow(r)
  {
    var root = r.parentNode;
    root.deleteRow(r);
  }
HTML代码:
<table>
  <tbody id="tbody">
    <tr>
        <td><select><option>hello</option><option>hi</option></select></td>
        <td><input type="text" value="enter you name here" /></td>
        <td><input type="text" value="text2"/></td>
        <td&g


相关文档:

使用javascript打开模态对话框

1. 标准的方法
<mce:script type="text/javascript"><!--

function openWin(src, width, height, showScroll){
window.showModalDialog (src,"","location:No;status:No;help:No;dialogWidth:"+width+";dialogHeight:"+height+";scroll:"+showScroll+";");
}
// --></mce:script> &n ......

JavaScript内置对象属性及方法大全


1.Date
属性(1):
constructor      所建立对象的函数参考
prototype       能够为对象加入的属性和方法
方法(43):
getDay()        返回一周中的第几天(0-6)
getYear()       返回年份.2000年以前为2位,2000 ......

JavaScript的另外两种继承机制

1>zInherit:
      它是一个组件,用来继承基类的所有属性和方法。跟以前说到的原型链模式非常类似,只不过比原型更安全,也无须考虑参数问题。下面看看zInherit的用法:
      该组件中只有两个方法:inheritfrom() instanceof()
     func ......

9.22 CSS复合属性和JavaScript在Html页面中的执行顺序

CSS复合效果
CSS的效果是可以重叠的,例如class="a b",那么这个节点就同时拥有了a和b的属性,并且,b可以覆盖a的属性。
JavaScript在Html中的执行顺序
经过简单测试,发现JavaScript的执行顺序是按照js的加载顺序进行的,而onload函数是在整个页面加载完成后才开始执行。
我的测试文件:
<!--
To change this ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号