Home > Web Front-end > JS Tutorial > body text

How to use jquery's after method

little bottle
Release: 2019-05-31 16:37:47
Original
3159 people have browsed it

jquery is a fast and concise JavaScript framework. It is another excellent JavaScript code library after Prototype. The purpose of jquery's design is "write less, do more", which means writing less code and doing more things. Now I will show you how to use jQuery’s after method?

How to use jquery's after method

after() method inserts the specified content after the selected element. If you need to insert content before the selected element, please use the before() method.

jquery video tutorial

Grammar

$(selector).after(content,function(index))
Copy after login
Parameters
Description
content
Required. Specifies the content to be inserted (can include HTML tags).
function(index)
Specifies the function that returns the content to be inserted. index - Returns the index position of the element in the collection.

Give me an example:

$("button").click(function(){

    $("p").after("<p>Hello world!</p>");
});
Copy after login

The above is the detailed content of How to use jquery's after method. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template