Method | Description | Example |
append() | Append content inside of each matching element |
HTML code: I want to say: jQuery code: $("p").append("Hello"); Result: I want to say:Hello |
appendTo() |
Append all matching elements to the specified element . In fact, using this method is to reverse the convention The operation of $(A).append(B) inis to append A to B. |
HTML code: I want to say: jQuery code: $("Hello").appendTo("p") Result: I want to say:Hello |
prepend() | Prepend content inside of each matching element | HTML code: I want to say: jQuery code: $("p").prepend("Hello") Result:
HelloI want to say:
|
Prepend all matching elements to the specified element . In fact, using this method is upside down Regular $(A).prepend(B) operation.
|
HTML code: I want to say: jQuery code: $("Hello").prependTo("p") Result:
HelloI want to say: |
|
Insert content after each matching element | HTML code: I want to say: jQuery code: $("p").after("Hello") Result: I want to say: Hello |
|
insertAfter() |
Insert all matching elements into the specified element After the element, actually, use this method Inverts the regular $(A).after(B) operation |
HTML code: I want to say: jQuery code: $("Hello").insertAfter("p") Result: I want to say: |
before() | Insert content before each matched element |
HTML code: I want to say: jQuery code: $("p").before("Hello") Result: Hello I want to say: |
insertBefore() |
Insert all matching elements into the index The front of a certain element. Actually, Using this method is to reverse the convention ’s $(A).before(B) operation. |
HTML code: I want to say: jQuery code: $("Hello").insertBefore("p") Result: Hello I want to say: |
The above is the entire content of this article, I hope you all like it.