Why do you want to erase it first? That isn't needed in order to upgrade OS X. See the following: Basic Steps for Upgrading OS X. However, if erasing is what you wish to do, then follow these steps:
Install or Reinstall OS X from Scratch
Be sure you have backed up your files because the following procedure will remove everything from the hard drive.
Boot to the Recovery HD:
Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears.
Erase the hard drive:
1. Select Disk Utility from the main menu and click on the Continue button.
2. After DU loads select your startup volume (usually Macintosh HD) from the
left side list. Click on the Erase tab in the DU main window.
3. Set the format type to Mac OS Extended (Journaled.) Optionally, click on
the Security button and set the Zero Data option to one-pass. Click on
the Erase button and wait until the process has completed.
4. Quit DU and return to the main menu.
Reinstall OS X: Select Reinstall OS X and click on the Install button.
Note: You will need an active Internet connection. I suggest using Ethernet if possible
because it is three times faster than wireless.
This should install the version of OS X that you had installed. You can now upgrade to El Capitan.
If your model came with Lion or later pre-installed, then you may prefer this method:
Install OS X Using Network Recovery
Be sure you have backed up your files because the following procedure will remove everything from the hard drive.
Boot to the Network Recovery Server:
Restart the computer and after the chime press and hold down the COMMAND-OPTION- R keys until a globe appears on the screen. Wait patiently - 15-20 minutes - until the Recovery main menu appears.
Partition and Format the hard drive:
- Select Disk Utility from the main menu and click on the Continue button.
- After DU loads select your newly installed hard drive (this is the out-dented entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
- Under the Volume Scheme heading set the number of partitions from the drop down menu to one. Click on the Options button, set the partition scheme to GUID then click on the OK button. Set the format type to Mac OS Extended (Journaled.) Click on the Apply button and wait until the process has completed. Quit DU and return to the main menu.
Reinstall OS X: Select Reinstall OS X and click on the Continue button. Be sure to select the correct drive to use if you have more than one.
Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.
This should restore the version of OS X originally pre-installed on the computer. You can now download and install El Capitan.
If your model came with Snow Leopard or earlier pre-installed then follow these steps:
Clean Install of Snow Leopard
Be sure you have backed up your files because the following procedure will remove everything from the hard drive.
1. Boot the computer using the Snow Leopard Installer Disc or the Disc 1 that came
with your computer. Insert the disc into the optical drive and restart the computer.
After the chime press and hold down the "C" key. Release the key when you see
a small spinning gear appear below the dark gray Apple logo.
2. After the installer loads select your language and click on the Continue
button. When the menu bar appears select Disk Utility from the Utilities menu.
After DU loads select the hard drive entry from the left side list (mfgr.'s ID and drive
size.) Click on the Partition tab in the DU main window. Set the number of
partitions to one (1) from the Partitions drop down menu, click on Options button
and select GUID, click on OK, then set the format type to MacOS Extended
(Journaled, if supported), then click on the Apply button.
3. When the formatting has completed quit DU and return to the installer. Proceed
with the OS X installation and follow the directions included with the installer.
4. When the installation has completed your computer will Restart into the Setup
Assistant. After you finish Setup Assistant will complete the installation after which
you will be running a fresh install of OS X. You can now begin the update process
by opening Software Update and installing all recommended updates to bring your
installation current.
Download and install Mac OS X 10.6.8 Update Combo v1.1. You can now download and install El Capitan.