【发布时间】:2021-07-07 21:36:42
【问题描述】:
我有一个奇怪的问题,所以在删除一行后更改了所有表行的 id。
这是我的代码的一部分:
$(document).on("click",".fa-trash-alt",function(){
console.log($(this).attr("id"))
let index = parseInt($(this).attr("id"))
globalFunctions.removeFromChoosedList(index)
$('tr#'+index).remove()
let rows = $(".choosed-table-data tr")
$.each(rows,function(index,value){
$(value).attr("id",index)
})
})
问题是,在此操作之后,当我单击应该具有新 id 的行时,尽管在检查器上更改了 id,但旧 id 仍显示为 console.log($(this).attr("id"))
【问题讨论】:
标签: javascript attributes attr