为了账号安全,请及时绑定邮箱和手机立即绑定

请问index表示什么意思?为什么点击两个按钮之后,返回的都是:index: 0

请问index表示什么意思?为什么点击两个按钮之后,返回的都是:index: 0

Helenr 2022-05-19 15:11:38
<!DOCTYPE html><html><head><script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><script>$(document).ready(function(){$("#btn1").click(function(){$("#test1").text(function(i,origText){return "Old text: " + origText + " New text: Hello world! (index: " + i + ")";});});$("#btn2").click(function(){$("#test2").html(function(i,origText){return "Old html: " + origText + " New html: Hello <b>world!</b> (index: " + i + ")";});});});</script></head><body><p id="test1">This is a <b>bold</b> paragraph.</p><p id="test2">This is another <b>bold</b> paragraph.</p><button id="btn1">Show Old/New Text</button><button id="btn2">Show Old/New HTML</button></body></html>
查看完整描述

1 回答

?
繁华开满天机

TA贡献1816条经验 获得超4个赞


<!DOCTYPE html><html><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script><script>$(document).ready(function(){  $("#btn1").click(function(){    $(".test1").text(function(i,origText){      return "Old text: " + origText + " New text: Hello world! (index: " + i + ")";     });  });        $("#btn1").click(function(){    $(".test1").html(function(i,origText){      return "Old text: " + origText + " New text: Hello world! (index: " + i + ")";     });  });});</script></head> <body><p class="test1">This is a <b>bold</b> paragraph.</p><p class="test1">This is another <b>bold</b> paragraph.</p><button id="btn1">Show Old/New Text</button><button id="btn2">Show Old/New HTML</button></body></html>


查看完整回答
反对 回复 2022-05-23
  • 1 回答
  • 0 关注
  • 324 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号