append(content)
将新的内容'content'附加在每一个匹配元素集合的元素后。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").append("<strong>Hello</strong>");
});
</script>
<style>p { background:yellow; }</style>
</head>
<body>
<p>I would like to say: </p>
</body>
</html>
$("p").append("<strong>Hello</strong>");
将新的内容‘<strong>Hello</strong>’附加到匹配的p元素内容之后。
本文介绍如何使用jQuery的append方法来动态地向已存在的HTML元素内部追加新的内容。通过一个具体的示例展示了如何将带有格式的文本添加到指定的<p>标签内。
388

被折叠的 条评论
为什么被折叠?



