Fixed undefined/wrong element bug when multiple tables existed, jQuery ports