Since the strings are involved, you have to change your strategy. Your table has four columns, so instead of deleting the first two columns, you should strive to keep only the last two.
This can be easily achieved by passing a negative upper bound to slice () :
$(this).children("td, th").slice(0, -2).remove();
Here you will find an updated script.
source share