<html>
<head>
<script?type="text/javascript"?src="/jquery/jquery.js"></script>
<script?type="text/javascript">
$(document).ready(function(){
??$("button").click(function(){
????$('p').addClass(function(n){
??????return?'par_'?+?n;
????});
??});
});
</script>
<style?type="text/css">
.par_0
{
color:blue;
}
.par_1
{
color:red;
}
</style>
</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>明明沒有傳入n,為什么n會自動為0 和1呢,兩個p標簽的顏色也被改了。
關于函數(shù)參數(shù)調用問題,求教
貓的第九尾
2015-12-07 17:50:49