<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").append(function(n){
return "<b>This p element has index " + n + "</b>";
});
});
});
</script>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>在每个 p 元素的结尾添加内容</button>
</body>
</html>
$("p").append(function(n){
return "<b>This p element has index " + n + "</b>";
请问上面一段代码中的n代表什么意思,是直接定义一个变量还是什么的
这个方法的n你可以理解为index,从0开始的,详见jqueryApi Append