A 17-year-old youth is on trial at Bradford Crown Court accused of sexually assaulting a girl aged 12.
The teenager, who was 16 at the time of the alleged assault on a day last spring, cannot be named for legal reasons.
He is said to have kissed the child at a house in Bradford and got on top of her to commit the assault.
Prosecutor Nick Askins said the youth stopped when the girl hit him.
She texted a friend to reveal what had happened and when her mother found out, the police were called.
The youth denies sexual assault of a girl under 13, saying nothing happened between them.