Shooting fireworks can be a bit tricky. There isn't enough time for the auto-focus to do its job. You're never quite sure exactly where you need to point your camera. And, it's nearly impossible to snap the picture at the exact right moment.
Here is my solution to capturing Independence Day fireworks. First, I set my camera to the Bulb setting. Sometimes this is found on the mode dial, on other cameras it will be the exposure setting after 30 sec. Next, I set my aperture to a mid-range setting, in this case f/8. I set the lens to manual focus and set the focus itself to Infinity.
Then, I attached the camera to a tripod and pointed to where the fireworks would be going off. Here, you might have to make some adjustments once the show actually starts.
I use a shutter release remote to capture the images. I press the button when the firework is shot off and release it once the explosion occurs. Sometimes I will keep the button pushed down in order to capture more than one going off in the same image. You have to be a little careful with this, though, because if you hold it down too long then the fireworks will start to look thin and stringy.
As always, just experiment and have fun!