Charlton pulled clear of the Championship relegation zone with a 2-1 win over 10-man Leicester in a pulsating end-to-end game.