How to get rid of fleas in an apartment with carpeted floors?
When I lived in an apartment, we had a problem with fleas once (due to a neglectful pet owner in the building).  Getting rid of the problem was no small feat, and took a lot of work over a few days.  

I started by laundering all bedding, clothing, and basically anything fabric that was washable.  Next I rented a steam cleaner, to clean the carpets. You can call in the pros for this if you don't want to do it yourself.  The final step was to spray the entire carpet; paying special attention to the edges and corners, with Adams™ Flea &amp; Tick Home Spray. Other brands exist, this was just the one I chose which worked for me.  

When using any chemical spray, make sure you have adequate ventilation. Try to avoid skin contact with chemical sprays as well. My wife had a bad reaction to the spray, where her feet swelled up quite a bit.

If you're in an apartment building; where the source of the infestation could be coming from other tenants, you'll also have to treat the other units.  If you don't remove the infestation from the entire building, you'll likely see the fleas return to your apartment.  Any outdoor pets in the building should also be treated, not only to combat the flea infestation but also for the health of the animal.