Avatar of canuckconsulting
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Need to animate buttons on webpage

I have a web page with buttons as shown here:
All the Buttons
They work fine but there is no visual indication when the get clicked.  What is the best and quickest way for me to visually respond to a click?  Here is one of the buttons files as an example:

Back Button
For image tools I have Gimp though I am a novice with it.  I also have the Jquery and jqueryUI libraries working on this page if that's of any use.
Web DevelopmentHTMLImages and Photos

Avatar of undefined
Last Comment

8/22/2022 - Mon

You can use jquery to do something like this easily.

Just give your images a class and a tabindex:
<img class="photo" tabindex="0" src="pic.jpg" />

Open in new window

Then use css to define a new image for your image when it has the focus (i.e. is clicked on).

Open in new window

Then use jquery to remove the focus after a short period of time:
$( ".photo" ).click(function() {

Open in new window

That should probably be a really easy way to do this.

you'll probably want to use a unique ID instead of a class as you'll need various css for the different pictures.  Forgot to do that.  Just define css for each unique ID and you can change the code accordingly.

Or to make your life easier you can change the color of the class's css and just modify the way the image looks when they click on it.  Like so:

	filter: saturate(500%);
	-webkit-filter: saturate(500%);
	-moz-filter: saturate(500%);
	-o-filter: saturate(500%);
	-ms-filter: saturate(500%);

Open in new window

You won't have to mess around with all those ID's in your CSS if you do it this way...

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks Nick!

Interestingly that doesn't work for IE but looks good in Chrome.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

Hmm.  I'm pretty new to jQuery, but I am pretty sure jQuery works very hard to be cross-browser compatible so the problem is probably elsewhere.  My guess is that IE doesn't allow you to set a tab index for elements like a img tag.

Solution, just fake IE out by using links...  Check out the solution for IE here

and remember you should be able modify the saturation (or other aspects) with the CSS i already gave you in an earlier comment so you don't have to specify unique images for each button and button focus.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.

Oh just found out CSS filter support is not in IE... So forget that idea...