how to dynamically change the source of an image when we click on it using shiny $ script tags


Using the following code I tried to change the src of the image img2 when its double clicked.

        $('#img2').on('dblclick', function(){ alert('dbl');
this.attr('src', 'absolute path to image'); } )")

The alert works, but the image doesn't get changed. What's the proper way to do this?

I don't know tag$script but your JQuery code looks good it should change your image on the fly when executed.