How jquery adds content to the end of div
Today, I would like to share with you the relevant knowledge points about how jquery adds content to the end of div. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
Add method: 1, with append (), syntax "$(" div "). Append (" content value ")", you can insert the specified content into the end of div; 2, with appendTo (), the syntax "$(" content value "). AppendTo (" div ")", you can insert the specified content into the end of the div.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
There are two ways for jquery to add content to the end of div:
Append () method
AppendTo () method
Note: although the functions of the appendTo () and append () methods are similar, both insert content into the "end" inside the selected element, but their operands are upside down.
1. Use the append () method
Syntax:
$(A) .append (B)
Indicates that B is inserted at the end of the inside of A.
Example:
$(document) .ready (function () {$("button") .click (function () {$("div"). Append ("this is new text content added to the end of div");}) Here are some texts.
This is a p paragraph in the div block.
Add content to the end of the div
2. Use the appendTo () method
Syntax:
$(A) .appendto (B)
Indicates that An is inserted at the end of the inside of B.
Example:
$(document) .ready (function () {$("button") .click (function () {$("this is a new span element") .appendTo ("div");}) Here are some texts.
This is a p paragraph in the div block.
Add content to the end of the div
These are all the contents of the article "how jquery adds content to the end of div". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.