现在的位置: 首页 > 综合 > 正文

appendTo

2012年09月02日 ⁄ 综合 ⁄ 共 424字 ⁄ 字号 评论关闭

appendTo方法在被选元素的结尾插入指定的内容。

<html>
<head>
<script type="text/javascript" src="/jquery/jquery.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>

亲自尝试:http://www.w3school.com.cn/tiy/t.asp?f=jquery_manipulation_appendto

抱歉!评论已关闭.