prepend(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").prepend("<b>Hello </b>");
});
</script>
<style>p { background:yellow; }</style>
</head>
<body>
<p>there friend!</p>
<p>amigo!</p>
</body>
</html>
$("p").prepend("<b>Hello </b>");
在匹配p元素集合中每一个p元素之前追加上新的内容‘<b>Hello </b>’。
本文介绍如何使用 jQuery 的 prepend() 方法,在匹配元素集合中每个元素的开始处插入指定的内容。通过实例演示了如何在 HTML 的段落元素前添加文本。
1748

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



