A. when using jquery ,
The Append () method inserts the specified content at the end of the selected element (still inside)
How to use:$ (selector). Append (content),content is required. Specify what to insert (can contain HTML tags)
two. when using native JS , use the appendchild () method to add a new child node to the end of the node's child nodes list.
Usage:Parent.appendchild (child); Child has no quotation marks to enclose, The child parameter, which is the node type. Create a dynamic element inside an empty document, using thedocument.body.appendChild (child).
Three. Example
<style> .test{ color: red; border:1px solid red; display: inline-block; font-size: 20px; width: 200px; height:50px; }</style>: Click the second p text segment to append a <strong>....</strong>
650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M02/7E/8C/wKioL1cEejTwO5UoAAAwB8CfdZo487.jpg "title=" 2.jpg " alt= "Wkiol1ceejtwo5uoaaawb8cfdzo487.jpg"/>
When the code in the JS native code implementation: Click on the first P-text segment, append a <strong></strong> after, and then add a text segment, and then append to the P-text segment after
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M01/7E/90/wKiom1cEec3g4vhgAAA4lsOPfxM049.jpg "title=" 1.jpg " alt= "Wkiom1ceec3g4vhgaaa4lsopfxm049.jpg"/>
Four. Disadvantages:
In the use of JS code implementation, the style aspects of the implementation of some small problems, in the future study, continue to supplement, perfect.
This article is from the "dream need to adhere to" blog, please be sure to keep this source http://xiyin001.blog.51cto.com/9831864/1760806
JS native Way to implement the Append () method in jquery