我有大约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() + "");
});
});
非常感谢你!!!!!!!!