jquery after() method


  Translation results:

after

UK[ˈɑ:ftə(r)] US[ˈæftə(r)]

prep.…after; (indicates time) in… Later; (indicating position and order) after...

conj.After...

adv.After, following

adj.Later, later

jquery after() methodsyntax

Function: after() method inserts the specified content after the selected element.

Syntax: $(selector).after(content

Parameters:

ParameterDescription
content Required. Specifies the content to be inserted (can include HTML tags).


Syntax:
Use the function to insert the specified content after the selected element.

Parameters: $(selector ).after(function(index))

Comment:

ParameterDescription
function(index)Required. Specifies the function that returns the content to be inserted.
index Optional. Receives the index position of the selector.

jquery after() methodexample

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("p").after("<p>Hello world!</p>");
  });
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<button>在每个 p 元素后插入内容</button>
</body>
</html>
Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A