Jquery USES the append of content method to share notes

  • 2020-03-30 01:16:26
  • OfStack

As the following example: append some HTML tags to all paragraphs.

HTML code:


<p>I would like to say: </p>

JQuery code:


$("p").append("<b>Hello</b>");

Results:

[< p> order I like to say: < b> Hello< / b> < / p>]

That's not a big deal, it's normal, but what if we do it the other way?

$(" p "). Append (" < B>" );

$(" p "). Append (" Hello< / b>" );

Results:

[< p> order I like to say: < b> < / b> Hello< / p>]

And that's what happened. Why did that happen?

I think when you call the append() function, it will automatically check whether the HTML content you added conforms to the standard.


Related articles: