append

UK [əˈpend] US [əˈpɛnd]

vt.Append; add; paste; sign (name)

jquery append() method syntax

Function: The append() method inserts the specified content at the end of the selected element (still inside). The append() and appendTo() methods perform the same task. The difference is: the position of the content and the selector.

Syntax: $(selector).append(content)

##Parameters:

ParameterDescriptioncontent Required. Specifies the content to be inserted (can include HTML tags). Use functions to append content.

Syntax: $(selector).append(function(index,html))

Parameters:

ParametersDescriptionfunction(index,html) Required. Specifies a function that returns the content to be inserted. index Optional. Receives the index position of the selector. html Optional. Receives the current HTML of the selector.

jquery append() method example

<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").append(" <b>Hello world!</b>");
  });
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>在每个 p 元素的结尾添加内容</button>
</body>
</html>
Run instance »

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