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
Release: 2016-05-16 17:03:18
Original
1094 people have browsed it
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");
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template