For more information about how Javascript works in iBooks – with some useful code examples – have a look at the "ibooks.js" file that resides inside the "Fixed Layout EPUB Example". Also, the iBooks Asset Guide (PDF) have a very informative section about Javascript in ePUBs. You can get both files with a
free books account in iTunes Connect.