Liam Andrew Henshaw said he had been drinking all day and could not remember the incident at the Red Lion pub on October 5 last year, Leeds Crown Court was told.
CCTV footage screened to the court showed the 21-year-old had been in the Market Place pub at around 11pm when he entered the dance floor with another, unidentified male.
Prosecutor Elizabeth Noble said it was unclear what took place next, but the unidentified male headbutted a man on the dance floor with Henshaw then throwing a punch at the victim to the side of his head, causing him to fall to the floor and appeared to leave him unconscious.
Henshaw, of Verner Street, Featherstone, is then seen trying to help the stricken man.
Shortly afterwards, a second man was then attacked by the unidentified male and while he was on the floor, Henshaw waded in and is seen punching the floored man five times to the back of the head.
It was later found that the first victim had suffered a fractured ankle, while the second man suffered a lump to the back of his head.
Henshaw eventually handed himself in to police after an appeal for put out on social media. He claimed he could not remember the attacks but admitted it was him and said he "felt awful about what happened".
A victim impact statement for the victim who suffered a broken ankle was read to the court, saying he had not been able to work due to the injury and was forced to apply for a mortgage break.
Henshaw, who has three convictions including wounding and drink driving, admitted charges of GBH and ABH.
Mitigating for the defendant, Sarah Cunnane, said: "It's not clear from any party why this happened but there is a lack of premeditation.
"He never went out with an assault in mind or targeted the complainants for any particular reason.
"He has demonstrated remorse from the outset."
Judge Robin Mairs labelled Henshaw's attack as an "act of great cowardice", but accepted it had not been planned.
He said: "It's unknown what started it but it was nothing that justified such needless violence."
He said that although it crossed the custody threshold, he was prepared to suspend the sentence due to his young age.
He gave him a two-year sentence, suspended for two years, told him to carry out 250 hours of unpaid work and to pay £2,000 compensation to the victim who was left with a broken ankle.
But he warned him that if was to land himself in any further trouble, he would be sent to jail.