1

How can i show image colored on mouseover?

My questions is similar to this jQuery script i follow for recursively changing images.

  • A grayscale image
  • A colored image

    $(document).ready(function () { $("#image").hover(function () { $(this).attr("src", "tpi/colored.jpg"); }, function () { $(this).attr("src", "tpi/grayscale.jpg"); }); }); 

Now is there any other way in css or jQuery with that i could do this without using two images at a time on hover?

4
  • 1
    Did i forget mentioning "I don't want to use two images" ? Why people answering me awkward. Commented Jun 18, 2013 at 11:58
  • @Manoz Look at my link. Only uses one image for most browsers, two for Firefox if you count an SVG filter. Commented Jun 18, 2013 at 11:59
  • 3
    OP, why edited post with again crazy indentation? Commented Jun 18, 2013 at 12:00
  • @Nile , surely the best i could do with. Commented Jun 18, 2013 at 12:00

1 Answer 1

2

Working DEMO in chrome http://jsfiddle.net/HF8c7/

-webkit-filter: grayscale(100%); 
Sign up to request clarification or add additional context in comments.

3 Comments

thankyou, so it has no cross-browser compatibility?
I have not checked it
for others, you may use rgba() to get to a close result: codepen.io/gcyrillus/pen/nqpDd , You have SVG filters as well avalaible for Firefox for instance

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.