JavaScript - - By Sam Deering

jQuery find index of last string

Quick jQuery snippet to insert into string at a specific index (or a last string). For example, to find the last position of a table row.

//find last position of 
 var lastRowIndex = $itemForm.lastIndexOf('');

You could then insert the string into the index of another string like so:

console.log($itemForm.substring(lastRowIndex, $itemForm.length));
$itemForm = $itemForm.substring(0,lastRowIndex) + "" + data.tableRowTemplate.html() + "" + $itemForm.substring(lastRowIndex, $itemForm.length);