Because of the helicity of electrons in HgTe quantum wells(QWs) with inverted band structures,the electrons cannot be confined by electric barriers since electrons can tunnel the barriers perfectly without backscattering in the HgTe QWs.This behavior is similar to Dirac electrons in graphene.In this paper,we propose a scheme to confine carriers in HgTe QWs using an electric-magnetic barrier.We calculate the transmission of carriers in 2-dimensional HgTe QWs and find that the wave-vector filtering effect of local magnetic fields can confine the carriers.The confining effect will have a potential application in nanodevices based on HgTe QWs.