jquery appendTo() method


  Translation results:

append

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

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

to

UK[tə] US[tu,tə]

prep.To; toward, toward; about;belongs to

adv.Toward one directional; to a certain state; to close

jquery appendTo() methodsyntax

Function: The appendTo() method inserts the specified content at the end of the selected element (still inside). Tip: The append() and appendTo() methods perform the same task. The differences are: the positioning of content and selectors, and the ability to use the append() function to append content.

Syntax: $(content).appendTo(selector

##Parameters:

ParameterDescriptioncontent Required. Specifies the content to be inserted (can include HTML tags).selector Required. Specifies which element to append the content to.

jquery appendTo() 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(){
    $("<b> Hello World!</b>").appendTo("p");
  });
});
</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