Home > Article > Web Front-end > How to use jquery's after method
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?
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.
Grammar
$(selector).after(content,function(index))
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>"); });
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!