Home >Web Front-end >JS Tutorial >jQuery methods for appending elements such as append, prepend, before_jquery

jQuery methods for appending elements such as append, prepend, before_jquery

WBOY
WBOYOriginal
2016-05-16 17:03:181094browse
1.jQuery append() method

The jQuery append() method inserts content at the end of the selected element.
Example
Copy code The code is as follows:

$("p").append ("Some appended text.");


2.jQuery prepend() method

jQuery prepend() method in the selected element Insert content at the beginning.
Example
Copy code The code is as follows:

$("p").prepend ("Some prepended text.");

3. after() and before() methods

jQuery after() method after the selected element Insert content.
The jQuery before() method inserts content before the selected element.
Example
Copy code The code is as follows:

$("img").after ("Some text after");
$("img").before("Some text before");
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn