Here is an overview of how to use the Web Inspector Tools to debug the Safari browser on the iPhone. You can also debug on an actual iPhone but the simulator that comes with Xcode should be sufficient in most situations. Below you will find the instructions on how to debug using the iOS Simulator.
- Mac OSX Lion (10.7.4) or higher
- Safari 6
- Xcode 4.5 or higher iOS6 SDK (available in the app store)