Jquery教程
Jquery动效
Jquery HTML/CSS
Jquery 事件
jquery常用

jQuery appendTo()

appendTo()方法用于在所选元素的末尾添加其他内容。它与jQuery append()方法相同。
语法:
$(content).appendTo(selector)

jQuery appendTo()方法的示例

让我们以一个示例来演示jQuery appendTo()方法。
<!DOCTYPE html>
<html>
<head>
<script src="/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("<span><b>Hello lidihuo.com</b></span>").appendTo("p");
    });
});
</script>
</head>
<body>
<button>Add new content at the end of each p element</button>
<p>I am a new reader.</p>
<p>I am also a new reader.</p>
</body>
</html>
输出:

I am a new reader.

I am also a new reader.

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4