JS native Way to implement the Append () method in jquery

Source: Internet
Author: User

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.