& lt table? id = ' test ' & gt? //Define a table
& lttr & gt
& lttd & gt& lt/TD & gt; & lttd & gt& lt/TD & gt;
& lt/tr & gt;
& lt/table & gt;
& lt script & gt
var? tb? =? document . getelementbyid(' test '); //Get the dom node of the table
var? td? =? tb.rows[0]。 Cell [0]; //Get the td cell with 0 rows and 0 columns.
td.innerHTML? =? '222'; //dynamically modify the contents of the table to 222.
& lt/script & gt;
& lt/body & gt;
Ideas:
1, get the dom node of the table
2. Locate td cells through rows and cells.
3. by modifying innerHTML
Extended data:
JS realizes the operation of adding, modifying and deleting dynamic tables.
First, the related JS function
Function setParamslist() {
var tab = document . getelementbyid(" tab ");
//Table row
var rows = tab . rows . length;
//Number of table columns
var cells = tab . rows . item(0). cells . length;
//alert(" rows "+rows+" columns "+cells);
var rowData =
for(var I = 1; I< line; i++) {
var cells data = new Array();
for(var j = 0; J< cells-1; j++) {
CellsData.push(tab.rows[i]. cell [j]. innerText);
}
row data = row data+" | "+cells data;
}
document . getelementbyid(" params list ")。 value = rowData
}
//Open the interface related to new application parameters.
Function openAppParamsPage() {
var param = new Object();
//This parameter must be passed.
param.win = window
param . id = 100;
param.name = " test
param . birthday = new Date();
var result = window . showmodaldialog(" addParamsItem "," dialog width:500 px; dialog height:600 px; dialog left:200 px; dialog top = 200 px ");
//var temp = document . getelementbyid(" params list ")。 Value;
//document . getelementbyid(" params list ")。 Value = temporary+result;
AddSort (result);
}
//Add application parameter function
Function addSort (data)
var name = data
if(name == ""||name==undefined ) {
Return;
}
Console.log (data);
var params = data.split(",");
var param name = params[0];
var param code = params[ 1];
var param value = params[2];
var row = document . createelement(" tr ");
row.setAttribute("id ",param code);
var cell = document . createelement(" TD ");
cell . appendchild(document . create text node(param name));
Row.appendChild (cell);
cell = document . createelement(" TD ");
cell . appendchild(document . create text node(param code));
Row.appendChild (cell);
cell = document . createelement(" TD ");
cell . appendchild(document . create text node(param value));
Row.appendChild (cell);
var delete button = document . createelement(" input ");
delete button . set attribute(" type "," button ");
delete button . set attribute(" value "," delete ");
delete button . onclick = function(){ delete sort(param code); };
cell = document . createelement(" TD ");
cell . appendchild(delete button);
Row.appendChild (cell);
document . getelementbyid(" sort list ")。 appendChild(row);
}
//Delete the application parameter function
Function deleteSort(id) {
If (id! =null){
var rowToDelete = document . getelementbyid(id);
var sort list = document . getelementbyid(" sort list ");
sort list . remove child(rowToDelete);
}
}
2. Pop-up box page, add or modify parameters, and write back relevant data.
& lt! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " " http://www . w3 . org/TR/XHTML 1/DTD/XHTML 1-Transitional . DTD " & gt;
& lthtml xmlns = " http://www . w3 . org/ 1999/XHTML " & gt;
& lthead & gt
& ltmeta http-equiv = " Content-Type " Content = " text/html; charset=utf-8" />
& lttitle & gt new application
& lt# include "/views/head . html "/& gt;
& lt/head & gt;
& ltbody & gt
& ltdiv class="body-box " >
& ltdiv class="clear " >& lt/div & gt;
& lt form & gt
& lttable width = " 100% " cellspacing = " 1 " cell padding = " 2 " border = " 0 " class = " pn-f table " >
& lttr & gt
& lttd & gt parameter name:
& lttd class="pn-fcontent " >& ltinput type = " text " maxlength = " 20 " class = " "? required="true "? id = " param name " name = " param name "/& gt; & lt/TD & gt;
& lt/tr & gt;
& lttr & gt
& lttd & gt parameter code:
& lttd class="pn-fcontent " >& ltinput type = " text " maxlength = " 20 " class = " "? required="true "? id = " param code " name = " param code " required = " true "/& gt; & lt/TD & gt; ?
& lt/tr & gt;
& lttr & gt
& lttd & gt parameter values:
& lttd class="pn-fcontent " >& ltinput type = " text " maxlength = " 20 " class = " "? required="true "? id = " param value " name = " param value " required = " true "/& gt; & lt/TD & gt; ?
& lt/tr & gt;
& lttr & gt
& lttd align="center" colspan="4 " >
& ltinput type = " submit " value = " save " onclick = " return result();" /& gt;
& ltinput type = " button " value = " Returns " onclick = " close window();" /& gt;
& lt/TD & gt;
& lt/tr & gt;
& lt/table & gt;
& lt/form & gt;
& lt/div & gt;
& lt/body & gt;
& lt/html & gt;
& ltscript type = " text/JavaScript " & gt;
//Close the window directly
Function closeWindow() {
window.close()。
}
//Get the value and return it after assembly.
Function returns the result () {
If (! $('form ')。 valid())
Return;
var param name = document . getelementbyid(" param name ");
var param code = document . getelementbyid(" param code ");
var param value = document . getelementbyid(" param value ");
//alert("value is "+paramName.value+","+paramCode.value+","+paramvalue.value);
var result = paramName.value +","+ paramCode.value +","+param value . value;
window.returnValue = result
window.close()。
}
& lt/script & gt;