Summary javascript code snippets and browser model_javascript skills related to AJAX
Source: Internet
Author: User
Summarize the JS code snippets and browser models related to AJAX in. net development, making full use of free controls is good, but if you cannot modify the controls to meet your needs, you need to use the JS method, the premise is to study the method attributes of various objects in the browser model. It is especially cool to be familiar with CSS + HTML. JS language itself does not have high requirements.
1. tips for dynamically deleting the content in the Table. you do not need to write too much code. one line:
Tb. removeNode (true)
2. add rows dynamically. in addition to the CreateElement method, it can be short as follows:
<Table id = tb1> </table>
<SCRIPT>
Function addTable (){
Var row1 = tb1.insertRow ();
Var cell1 = row1.insertCell ();
Var cell2 = row1.insertCell ();
Cell1.innerText = "baby gray beans ";
Cell2.innerText = "super stupid Wolf"
}
</SCRIPT>
<Input type = "button" VALUE = "AddTable" onclick = "addTable ()">
3. dynamically add Table 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 ();
Myp. appendChild (tb1 );
Cell1.innerText = "wanghr100 ";
Cell2.innerText = "panyuguang962"
}
</SCRIPT>
<BODY>
<P id = myp style = "width: 400; height: 300;"> </p>
<Input type = "button" VALUE = "AddTable" onclick = "addTable ()">
4. delete the Table in the DIV, as long as Div. innerHTML = "" is simple.
The above is part of the relatively short practical code. Of course there are other methods to achieve this, but it is generally longer than the above, such as combining the insertAdjacentHTML method of the DIV object, etc, the premise of using different methods under different needs is to study the method attributes of various objects in the browser model. It is especially cool to be familiar with CSS + HTML. JS language itself does not have high requirements.
The Document object is used as an example. the related methods include:
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service