<title> JS Dom getElementById Instance Tutorial </title>
<body>
<span id= "Span1" >hello,ajax!</span>
</body>
<script language= "JavaScript" type= "Text/javascript" >
<!--
var Span1=document.getelementbyid ("Span1");
Change the contents of a node using the innerHTML property
Span1.innerhtml= "InnerHTML changed";
-->
</script>
The above is a simple example of how the DOM operates on a table
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title>table test</title>
<body>
<div id= "Tabletest" >
</div>
</body>
<script language= "JavaScript" type= "Text/javascript" >
<!--
Get a reference to a container div
var Container=document.getelementbyid ("Tabletest");
Create a Table object
var _table=document.createelement ("table");
Set Table Properties
_table.setattribute ("Border", "1");
_table.setattribute ("BorderColor", "Black");
_table.setattribute ("width", "200");
Create 5 lines
for (Var i=0;i<5;i++) {
var _tr=document.createelement ("tr");
Create 4 columns
for (Var j=0;j<4;j++) {
var _td=document.createelement ("TD");
var _tn=document.createtextnode (i.ToString () +j.tostring ());
_td.appendchild (_TN);
_tr.appendchild (_TD);
}
_table.appendchild (_TR);
}
Display a table on a page
Container.appendchild (_table);
-->
</script>