设置p的text的一个有关问题,求指教:)
设置p的text的一个问题,求指教:-)
点击几次之后,p的内容变成:old:old:old:old:old:old:old:hello world new:0 new:0 new:0 new:0 new:0 new:0 new:0。无法理解,i和ot都是怎么来的呢? 求大神指教!
------解决思路----------------------
function(index,oldcontent)
index - 可选。接受选择器的 index 位置。
html - 可选。接受选择器的当前内容。
http://www.w3school.com.cn/jquery/manipulation_text.asp
------解决思路----------------------
jquery写好了的! 那个事件处理函数绑定的时候是默认有参数的!
<p id="pid3">hello world</p>
<button id="btn3">改变p的内容</button>
$('#btn3').click(function(){
$('#pid3').text(function(i, ot){
return "old:" + ot + " new:" + (i);
});
})
点击几次之后,p的内容变成:old:old:old:old:old:old:old:hello world new:0 new:0 new:0 new:0 new:0 new:0 new:0。无法理解,i和ot都是怎么来的呢? 求大神指教!
------解决思路----------------------
function(index,oldcontent)
index - 可选。接受选择器的 index 位置。
html - 可选。接受选择器的当前内容。
http://www.w3school.com.cn/jquery/manipulation_text.asp
------解决思路----------------------
jquery写好了的! 那个事件处理函数绑定的时候是默认有参数的!