A quickie, is it possible to have an image darkened using javascript or something?
I don’t need it on mouseovers or anything, just for the image to appear disabled (could I change the opacity of it using a style tag even?).
How would I do?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
The simplest method is to use opacity on the
imgand, if necessary, a background element with the color you want to add (note that opacity is somewhat browser and version dependent, this example works in Firefox, Chrome and I assume other Webkit browsers):http://jsfiddle.net/Sctkz/1/
And as David Thomas points out, if you are working with an with an alpha-transparency, you can add the
background-colorto theimgitself:http://jsfiddle.net/GfkeF/
According to Quirksmode, full IE support using compatibility views can be gained adding:
Otherwise, as Ktash and MDN note, you can use simply: