ajax|js| Browser
In. NET development, it is good to make full use of free controls, but if you cannot modify the control to meet your own needs, you will need to use JS Dafa, provided that you study the method properties of the various objects of the browser model. Especially familiar with the css+html will do very cool. As for the JS language itself, the requirements are not high.
1, the dynamic deletion of table content tips, do not need to write too much code, a line:
Tb.removenode (True)
2, dynamically increase the line, in addition to the CreateElement method, but also this relatively short:
<table id=tb1></table>
<SCRIPT>
function addtable () {
var row1 = Tb1.insertrow ();
var Cell1=row1.insertcell ();
var Cell2=row1.insertcell ();
cell1.innertext= "Gray peas Baby";
cell2.innertext= "Super Big Stupid Wolf"
}
</SCRIPT>
<input TYPE = "button" VALUE = "addtable" onclick = "addtable ()" >
3, add table dynamically in Div
<SCRIPT>
function addtable () {
var tb1 = document.createelement ("table");
Tb1.border= "1px";
var row1 = Tb1.insertrow ();
var Cell1=row1.insertcell ();
var Cell2=row1.insertcell ();
Mydiv.appendchild (TB1);
cell1.innertext= "wanghr100";
cell2.innertext= "panyuguang962"
}
</SCRIPT>
<BODY>
<div id=mydiv style= "width:400;height:300;" ></div>
<input TYPE = "button" VALUE = "addtable" onclick = "addtable ()" >
4, delete table in Div, simple as long as div.innerhtml= "" can.
The above is a few practical relatively short code, of course, there are other ways to achieve, but generally more than the length of the above, such as the combination of the use of Div object insertAdjacentHTML method, in different needs under different methods, the premise is to study the browser model of the various objects of the method attribute. Especially familiar with the css+html will do very cool. As for the JS language itself, the requirements are not high.
The following are examples of document objects:
Method Description
Attachevent
CreateAttribute
Createcomment
Createdocumentfragment
CreateElement
Createeventobject
createStyleSheet
createTextNode
DetachEvent
getElementById
Getelementsbyname
getElementsByTagName
Mergeattributes
Recalc
Write
Writeln
Take a Div object as an example related methods are:
Addbehavior
AppendChild
Applyelement
Attachevent
Clearattributes
CloneNode
Contains
DetachEvent
Getadjacenttext
GetAttribute
GetAttributeNode
getElementsByTagName
HasChildNodes
Insertadjacentelement
insertAdjacentHTML
insertAdjacentText
InsertBefore
Mergeattributes
Normalize
RemoveAttribute
Removeattributenode
Removebehavior
RemoveChild
Removeexpression
Removenode
Replaceadjacenttext
ReplaceChild
ReplaceNode
SetActive
SetAttribute
Setattributenode
SetExpression
Other, such as Drop-down list objects, and drag-and-drop operations and so I have time to collate and compare, to achieve the same function, relatively short of the wonderful code is worth collecting.