Open the Save Image dialog using jQuery/Javascript?

后端 未结 5 372
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 16:10

When a user clicks on an image on a web page, I\'d like to trigger the browser\'s Save Image dialog and to let the user save the image on their hard drive. Is there a cross-

5条回答
  •  生来不讨喜
    2020-12-05 16:33

    you can create a hidden file-input field and trigger() this one, when you click on your image:

    $('.yourImageClass').click(function(){
     $('.hiddenInputClass').trigger('click');
    })
    

提交回复
热议问题