Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8481881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:40:51+00:00 2026-06-10T19:40:51+00:00

There is more code to each function, but these are the main lines that

  • 0

There is more code to each function, but these are the main lines that matter in regards to my question I believe…This is from a guys library to desaturate an image on rollover basically.

How do I change it to on click, rather than on mouseover / rollover? Here’s his code…

jQuery(function($){
$cloned.closest(".DesaturateDiv").bind("mouseenter mouseleave",desevent);
}

  function desevent(event) 
  {
    if (event.type == 'mouseenter')
         $(".des.color", this).fadeOut(275);

    if (event.type == 'mouseleave')
        $(".des.color", this).fadeIn(200);
  }

I’ve already tried changing both if statements to a jquery toggle as well as changing the top line from .bind(“mouseenter mouseleave”, desevent) … to .bind(“toggle”, desevent) and it still didnt work. my question is basically how to substitute mouseenter and mouseleave to onClick so the image desaturates onClick then saturates again onClick. Heres my toggle code that I put in instead of the two if’s above, just incase.

$('.DesaturateDiv').toggle(function() {

$(".des.color", this).fadeOut(275);

}, function() {
$(".des.color", this).fadeIn(200);
});

Also, on a related note, could you do this with css3?
here’s the code to desaturate an image with css3…

 img.desaturate{
filter: grayscale(100%);
-webkit-filter: grayscale(100%); -moz-filter: grayscale(100%);
-ms-filter: grayscale(100%); -o-filter: grayscale(100%);
filter: url(desaturate.svg#greyscale);
filter: gray;
-webkit-filter: grayscale(1);
}

So my question would be how to do it oncick?

I tried img.desaturate:active{} but it didn’t work?

EDIT: I tried this and think something along these lines is what I need but im sure the syntax is not correct, help??

 function desevent(event) 
  {
    i = 0;

    if( i = 0 ){
    if (event.type == 'mousedown')
         $(".des.color", this).fadeOut(275);
         i = 1;
    }

    if( i = 1 ){
    if (event.type == 'mousedown')
        $(".des.color", this).fadeIn(200);
                     i = 0;
    }
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:40:53+00:00Added an answer on June 10, 2026 at 7:40 pm

    Just add a specific class to the clicked element.

    .desaturate{
        transition-duration: 400ms; //and other prefixes
    }
    .desaturate.active{
        filter: grayscale(100%);
        -webkit-filter: grayscale(100%); -moz-filter: grayscale(100%);
        -ms-filter: grayscale(100%); -o-filter: grayscale(100%);
        filter: url(desaturate.svg#greyscale);
        filter: gray;
        -webkit-filter: grayscale(1);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anything wrong with this code or can this be done more efficiently?
Here is my code: $(document).ready(function(){ //These variables are for loading more posts var create_ptr
The following code works, but I'm sure there is a more compact way to
Is there more elegant (less code) way of find a matrix OUT, with colSums(OUT)<=a
There Currently is a local debate as to which code is more readability We
in the code below at first if statements block (there will be more than
I was wondering if there was a more efficient (efficient as in simpler/cleaner code)
I'm trying to reorganize my code and make it more unobstrusive. Mainly, there is
please help me to identify which of these following is more optimized code? for(int
I have added a show more or less function to a div - this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.