How can I stop my toddler from hitting me when he’s mad?

He does this and also pulls my hair or tries to bite me...idk where he got this from it just randomly started happening. When he doesn’t get what he wants or I tell him “no” he does this. I try to tell him no and pretend to cry but that doesn’t work anymore ( as in anymore because back then when I would pretend to cry he would give me a hug but he doesn’t do that anymore) I have also tried giving him a slap on the hand or on his butt. Doesn’t work either.

Idk what to do? Should I talk to his dr about this?

Ohhhh and pleaseeee no back lash, I’m going back on here to seek help not criticism.