The first day of Javascript

container.appendChild (mes);
document.body.appendChild (container);
var newpara = container.cloneNode (true); / / true and false distinction
document.body.appendChild (newpara);

var newpara = container.cloneNode (false); / / true and false distinction
document.body.appendChild (newpara);
</ SCRIPT>
Firebug facie result:

See the difference between true and false instead.
true, then: Yes <p> hello world </ p> cloning.
false: Cloning only <p> </ p>, the text of which is not cloned.
And createElement (), the cloning of the new node will not be automatically inserted into the document. Need to appendChild ();
Another Note: If, after cloning, id like, do not forget to use setAttribute ( "id", "new_id");
To change the new node ID.

4, insert the node. appendChild ():
Used several times in front of all, we should all know about the usage of the.
Specific explanation is that:
Additional elements to a subset of nodes, the new node inserted into the final.
var container = document.createElement ( "p");
var t = document.createTextNode ( "cssrain");
container.appendChild (t);
document.body.appendChild (container);

In addition appendChild () can be used not only new element added, you can also move elements of the existing document.
See the following examples:
<p> msg </ p>
<p> content </ p>
<p> aaaaaaaa </ p>
<script>
var mes = document.getElementById ( "msg");
var container = document.getElementById ( "content");
container.appendChild (mes);
</ script>
/ / Find msg behind on content.
Js internal treatment:
ID for the first msg to delete from the document, and then inserted into the content after the content as the last inserted node.
Results as follows:
<p>
content
<p> msg </ p>
</ p>
<p> aaaaaaaa </ p>

5, insert the node. insertBefore ():
As the name suggests, is to insert a new node to the target in front of the node.
Element.insertBefore (newNode, targerNode);
/ / Note the first parameter is the new node, followed by the target node (insert location).
/ / New node is the guest of his first serve pyronaridine sure. . . ^ _ ^

The second parameter is optional, if not to write the second parameter will be added to the default of the final document, which is equivalent to appendChild ();
Let us look at the insertBefore () how to use:
<div>
<p> 1111 </ p>
<div> msg <div> test </ div> </ div>
<p> 222 </ p>
<p> aaaaaaaa </ p>
</ div>
<script>
var msg = document.getElementById ( "msg");
var aaa = document.getElementById ( "aaa");
var test = document.getElementById ( "cssrian");
test.insertBefore (msg, aaa);
</ script>
/ / We found the insertion of ID for the msg to the front of aaa.
Js-house approach with appendChild () is similar. Is:
ID for the first msg to delete from the document, and then inserted into pre-aaa, aaa, as inserted in front of a node.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of The first day of Javascript

  • hibernate using c3p0 connection pooling

    Private http://www.lifevv.com/tenyo/doc/20070605102040991.html c3p0 for open source's JDBC connection pool, with the release hibernate. This article describes how to use the hibernate configuration in c3p0. c3p0 connection pool configuration is v ...

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.1 ...

  • hibernate generic generic DAO

    hibernate generic generic DAO

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

Leave a Reply

Recent
Recent Entries
Tag Cloud
Random Entries