Hi There,
That code works, I just test it on my end. The issue is with the ID, ID should be unique no element should have same ID. You can use a class instead, however your code is only for one image. You need your code to be more dynamic or you can add another instance of the code with different ID.
Thanks.