jQuery after()メソッド
例
各<p>要素の後にコンテンツを挿入します。
$("button").click(function(){
$("p").after("<p>Hello world!</p>");
});
定義と使用法
after()メソッドは、選択された要素の後に指定されたコンテンツを挿入します。
ヒント:選択した要素の前にコンテンツを挿入するには、 before()メソッドを使用します。
構文
$(selector).after(content,function(index))
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (can contain HTML tags)
Possible values:
|
function(index) | Specifies a function that returns the content to insert
|
自分で試してみてください-例
after()メソッドを使用してコンテンツを挿入します。
挿入する関数を使用して、選択した要素の後にコンテンツを挿入する方法。