Use prevAll/nextAll instead of prev/next so it does not mind if there is script elements in the table