How to run custom JavaScript code on gallery attachment image selection

How to run custom JavaScript code on gallery attachment image selection