Potassium helps control muscle function in the body and can have a direct impact on leg cramps, according to Everyday Health and MedlinePlus. Potassium is an electrolyte, and too little can result in muscle cramps or more serious side effects.
Many professional athletes recommend consuming potassium-rich foods such as bananas after physical exertion, according to Everyday Health. Cramps in the legs can also be caused by other conditions such as dehydration, calcium deficiency and vigorous exercise. Certain medications, such as diuretics, birth control and steroids, may also cause muscle cramps. Eating a fruit- and vegetable-rich diet and staying hydrated may help alleviate leg cramps.