快速jQuery片段,可在特定索引 (或最后一个字符串) 处插入字符串。 例如,查找表行的最后位置。
//find last position of
var lastRowIndex = $itemForm.lastIndexOf('');
console.log(lastRowIndex);
然后可以将字符串插入另一个字符串的索引中,如下所示:
console.log($itemForm.substring(lastRowIndex, $itemForm.length));
$itemForm = $itemForm.substring(0,lastRowIndex) + "
" + data.tableRowTemplate.html() + "" + $itemForm.substring(lastRowIndex, $itemForm.length);
console.log($itemForm);