JQuery change hue, saturation, gamma of ?

前端 未结 6 1324
日久生厌
日久生厌 2021-02-04 14:58

I want to make an image darker if you hover your mouse over it. Is it possible to change the hue, saturation or gamma of an img with JQuery (or Javascript)?

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 15:50

    It is not possible to do this using only JavaScript (since it can't manipulate binary files), however you can do this with the HTML5 element to help.

    Take a look here, there are some libraries out there to help.

    If you just want to fade it, change the opacity on hover, for example:

    $("img").css({ opacity: 0.5 }).hover(function() {
      $(this).animate({ opacity: 1 });
    }, function() {
      $(this).animate({ opacity: 0.5 });
    });
    

提交回复
热议问题