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

JavaScript如何动态的设置表格的样式


二、动态给表插入行:
function addRow(){
  //动态插入一行
  var oRow1=mediaMes.insertRow(mediaMes.rows.length);
  //设置tr的id
  oRow1.id="tr"+thisId;
  //获得表总的行数
  var aRows=mediaMes.rows;
  //获得新添加行的列集合
  var aCells=oRow1.cells;
  //再新添加的行里面插入一个列
  var oCell1_1=aRows[oRow1.rowIndex].insertCell(aCells.length);
  //=================设置列的样式======================
  oCell1_1.align="center";
  var oStyle1 = oCell1_1.getAttribute("style");
  //Ie浏览器动态设置样式不能直接给行或列指定class属性
  //要先把样式放到一个对象的attribute里面,然后在把这个对象设置到行或列里面去
  // ie
     if(oStyle1 == "[object]") {
      oStyle1.setAttribute("cssText","border-right: 1px solid #003399;border-bottom: 1px solid #003399;");
        oCell1_1.setAttribute("style",oStyle1 );
     } else {
   oCell1_1.setAttribute("class","td_border" );
     }
  var cell1="<input type='text' name="user"  id='user'/>";
  oCell1_1.innerHTML=cell1;
}


相关文档:

简洁强大的JavaScript表单验证程序

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>vForm表单验证程 ......

JAVASCRIPT访问父窗口的变量或方法


AA.HTM
-------------------------------------
<!--
showModalDialog函数的使用   (转)     
本范例可以实现弹出一个模态窗口,并演示了两种接收和传递参数的方法,同时可以接受模态窗口返回的多个变量   
-->
<html>    &nbs ......

Javascript 之apply()

1、对象的继承,一般的做法是复制:Object.extend
prototype.js的实现方式是:
Object.extend = function(destination, source){
for (property in source) {
destination[property] = source[property];
}
return destination;
......

JavaScript字符串函数大全


JS自带函数
concat
将两个或多个字符的文本组合起来,返回一个新的字符串。
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
返回字符串中一个子串第一处出现的索引(从左到右搜索)。如果没有匹配项,返回 -1 。
var index1 = a.indexOf("l");
//index1 = 2 ......

利用javascript验证邮箱地址是否合法

源代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>验证邮箱地址合法性</title>
    <sc ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号