Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery color animation problems

Featured Replies

$(document).ready(function () {
$("#nav li.current-page a").animate({color:"#3ea8bd"}, 1800);	
$("#nav li.current-page a span").animate({color:"#9bd7e3"}, 1800);
});

 

Can somebody please tell me why this little bit of jQuery is causing so many problems for me. Most of the time it works but other times it totally fails to have any effect - the problem is especially prominent in Safari 4 on mac.

 

I feel like I'm missing something really basic!

 

You can see the actual page in action here if that helps: http://positive-intent.com/beta/

 

Thanks in advance for any answers :-)

The ability to animate the color properties isn't built into the jQuery core. You either need the colour plugin, or i think it may be built into jQuery UI.

 

Just a suggestion.

  • Author

thanks bocaj sorry i should have mentioned i'm already using the color plugin

  • Author

ok i'm still having no luck with this problem. i'd say about 30% of the time on Safari it works. I cant even figure out what is causing the problem... let alone find a way to fix it. I'd really appreciate an answer if someone has one.

 

thanks again! :-)

I use jQuery and the colour (fade) all the time. If something's not working start a blank page and code JUST the colour animation with the minimum amount of unnecessary code. There doesn't appear to be a class "current-page" either so that code isn't going to work as it is and I'm not sure if you can target the span (although you should be able to). Also you're trying to animate the same link in two different ways. The point is make the code simple to ensure it's working.

 

The code you posted will animate on document ready not on a (useful) event (like a mouseover). I'd also add a .stop() on event animations to prevent cue build up.

 

Try to animate all the links on the page, without targeting specific ones.

 

$(document).ready(function () {
       $("a").animate({color:"#3ea8bd"}, 1800);  
});

  • Author

Thanks Mesa. yes animating all links does work that way so the problem is probably with attempting to animate two parts of the same links.

 

The class current-page is used on every page other than the first and the effect works almost always on all browsers except safari where 20% of the time it fails for no apparent reason. Also I want the links to fade in on document ready which is why I did not include a specific event.

 

Do you have any idea why safari would have a sporadic problem and not the others?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.