jQuery中append、insertBefore、after与insertAfter方法注意事项_jquery
这里列的是针对初学jQuery者来说容易搞不懂的部分,我在这里把这些方法列了个清单,希望大家能看的懂。如下:
方法 |
源包装集/字串 |
目标包装集体 |
特性描述 |
A.append(B) |
B |
A |
若目标包装集只匹配一个元素,则源(也包括同源包装集匹配的所有元素)将被移动到目标位置;若目标包装集包含多个元素,则源将保留在原来的位置,但同时复制一份相同的副本到目标位置。 由此,若目标只匹配一个元素时,使用前述方法后源将被删除。 |
B.appendTo(A) |
|||
A.prepend(B) |
|||
B.prependTo(A) |
|||
A.before(B) |
|||
B.insertBefore(A) |
|||
A.after(B) |
|||
B.insertAfter(A) |
举例说明:在上图中,A.append(B)表示把B添加到与A匹配的所有元素的现有内容后面,因此B是源,A是目标包装集。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Usage: In JavaScript, the insertBefore() method is used to insert a new node in the DOM tree. This method requires two parameters: the new node to be inserted and the reference node (that is, the node where the new node will be inserted).

Use Java's StringBuilder.append() function to splice strings. In Java programming, string splicing is a very common operation. In order to efficiently splice strings, Java provides the StringBuilder class, whose append() function can quickly join multiple strings together. StringBuilder is a variable character sequence that is more efficient to use than the String class. When we need to concatenate a large number of strings, use

The difference between insertbefore and before: 1. Usage; 2. Parameters; 3. Return value; 4. Compatibility; 5. Performance; 6. Selector; 7. Automatic creation of elements; 8. Error handling; 9. Cleaning; 10. Chain call; 11. Other differences. Detailed introduction: 1. Usage, insertBefore is a DOM method that can be called directly on any DOM element, before is a jQuery method that can only be called on jQuery objects; 2. Parameters, etc.

How to use the append() method of the StringBuilder class to splice strings in Java. Splicing strings is a common operation in Java. During the splicing process, if the basic String class is used for string addition, new String objects will be created frequently, thus affecting performance. In order to solve this problem, Java provides the StringBuilder class to perform string splicing operations. StringBuilder class is one of the Java

In Python, append() is a method of the list object that is used to add an element to the end of the list. It should be noted that the append() method can only be used for list objects and cannot be used for other types of objects. In addition, the append() method will directly modify the original list without returning a new list.

append is a commonly used command line tool used to append the contents of one file to the end of another file. The usage of the append command is "append [option] source file target file", where the source file is the file to be appended and the target file is the file to be appended.

Interpretation of Java documentation: Detailed introduction to the append() method of the StringBuilder class. Java provides the StringBuilder class as a variable string type. This class provides a series of methods to operate strings. One of the most commonly used methods is append( )method. This article will introduce the append() method of the StringBuilder class in detail and attach specific code examples. StringBuilder class is in Java

What are the pseudo-element selectors? Specific code examples are required. The pseudo-element selector is a powerful selector in CSS that allows us to insert specific elements before or after the content of the element and style these pseudo-elements. Pseudo element selectors are usually represented by double colons (::). In this article, we will discuss some commonly used pseudo-element selectors and give specific code examples. ::before pseudo-element selector: This selector inserts a pseudo-element before the matching element. Code example:
