Hedges, 21, spent the first half of the season on loan at League Two Yeovil, scoring five goals in 28 appearances.
Australia youth international Elder, 22, will stay with the Tykes for the rest of the season.
He follows Matty James by leaving the Foxes to join the Championship side, having been on loan with Brentford.
Wales Under-21 international Hedges never played a senior game for Swansea, but has also had loan spells with Leyton Orient and Stevenage.
Find all the latest football transfers on our dedicated page or visit our Premier League tracker here.
Barnsley have signed Swansea forward Ryan Hedges on a two-and-a-half-year deal, as well as loaning defender Callum Elder from Leicester.