On the zeros of certain polynomials related to Jacobi and Laguerre polynomials