Notes for using the append (content) method in jquery

Source: Internet
Author: User

Notes for using the append (content) method in jquery

The append (content) function appends content to each matching element. You need to pay attention to the usage. For more information, see the following example.

For example, add HTML tags to all paragraphs.

 

HTML code:

The Code is as follows:

<P> I wowould like to say: </p>

 

 

JQuery code:

 

The Code is as follows:

$ ("P"). append ("<B> Hello </B> ");

 

Result:

 

[<P> I wowould like to say: <B> Hello </B> </p>]

 

It seems that there is nothing. It's normal. What if we try to append it in another way?

 

$ ("P"). append ("<B> ");

 

$ ("P"). append ("Hello </B> ");

 

Result:

 

[<P> I wowould like to say: <B> </B> Hello </p>]

 

The result is like this. Why?

 

When I call the append () function, it will automatically check whether the html content you added meets the standard. If yes, it will be added normally. If not, then it will automatically generate display that meets the so-called standards.

 

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.