It doesn’t work in the preview, nor in the live site. But the latter prints “Uncaught (in promise) TypeError: $w(…).previous is not a function” and “Uncaught (in promise) TypeError: $w(…).next is not a function” in the console.
@louvens I don’t know. If it is still doesn’t work, maybe the gallery you chose does not support .next(), previous().
And anyway, you’re better put the event handler inside the $(‘#dataset’).onReady(){} of the dataset that bound to the gallery (I don’t think it will resolve that issue though).