Summarize AJAX-related JS code snippets and browser model _javascript skills
Source: Internet
Author: User
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, dynamic Delete table inside the content skill, do not need to write too many code, a line:
Tb.removenode (True)
2, dynamic increase 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, in the div delete table, 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 content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.