html语言里面的li,html – 如何替换“li”中的文本

我有大约100页的所有< ul> – 问题是,我需要将每个列表项包装在< span>中.我已添加以下代码

  • ICD-10 transition
  • Pricing transparency
  • Patient and payor mix fluctuation

$(document).ready(function () {

$("li").each(function (index) {

$("li:nth-last-child(" + index + ")").append(" " + $("li:nth-last-child(" + index + ")").text() + "");

});

});

这是我得到的结果:

ICD-10 transition ICD-10 transition ICD-10 transition

Pricing transparency Pricing transparency Pricing transparency

Patient and payor mix fluctuation

Patient and payor mix fluctuation Patient and payor mix fluctuation

当我只希望代码运行一次并替换代码一次而不是两次时,代码被替换两次.我想知道如何解决这个问题,但更多的是为什么这首先发生在一起.该方法没有被调用两次 – 所以它为什么会发生.

非常感谢你们帮助我弄清楚!!!我得到了它…

$(document).ready(function () {

$("li").each(function (index) {

$(this).html("" + $(this).html() + "");

});

});

非常感谢你!!!!!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值