Error message: Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'.
I want to concatenate the string after the corresponding tr when the addChild method is triggered. How should I write addChild?
-----renew
Dear friends who answered, thank you, the problem is solved, I used the method on the first floor
第一个参数要求是Dom节点不是字符串
试试
insertAdjacentHTML
tpl是个字符串,不是一个node对象,所以报错;
你可以利用事件冒泡,把addChild方法写在tr或者tbody上(依据是否是每个tr都需要这个方法),
然后利用event对象的target属性来找到对应的tr,然后进行后面操作就可以了;
报错信息很明显了,tpl是一个字符串,不是一个node元素
https://developer.mozilla.org...
你得把字符串转成dom
比如类似这样的函数,来讲字符串转成dom,代码仅做参考