Resonant inelastic x-ray scattering (RIXS) experiments performed at the oxygen K edge on the iridate perovskites Sr2IrO4 and Sr3Ir2O7 reveal a sequence of well-defined dispersive modes over the energy range up to ∼0.8eV. The momentum dependence of these modes and their variation with the experimental geometry allows us to assign each of them to specific collective magnetic and/or electronic excitation processes, including single and bimagnons, and spin-orbit and electron-hole excitons. We thus demonstrate that dispersive magnetic and electronic excitations are observable at the O K edge in the presence of the strong spin-orbit coupling in the 5d shell of iridium and strong hybridization between Ir 5d and O 2p orbitals, which confirm and expand theoretical expectations. More generally, our results establish the utility of O K-edge RIXS for studying the collective excitations in a range of 5d materials that are attracting increasing attention due to their novel magnetic and electronic properties. Especially, the strong RIXS response at O K edge opens up the opportunity for investigating collective excitations in thin films and heterostructures fabricated from these materials.