For example when I copy the link from an answer and access it, a nice block of color appears to highlight the answer and then is fading out. How this is done?
Asked
Active
Viewed 156 times
0
-
possible duplicate of [How do you fade in/out a background color using jquery?](http://stackoverflow.com/questions/967815/how-do-you-fade-in-out-a-background-color-using-jquery) ... please use the search before you ask a question. – Felix Kling Oct 13 '11 at 06:41
-
Use your imagination and Firebug. – Yves M. Oct 13 '11 at 06:42
1 Answers
3
It looks at the hash, selects that answer, and then animates the background color. Either use jQuery UI or add the Colors plugin to be able to animate colors.
This is what the code may look like...
var hash = window.location.hash;
if (hash) {
var answer = $('#answer-' + hash.substr(1)),
originalBackgroundColor = answer.css('backgroundColor');
// This class changes the background colur.
// Best to keep style stuff in the CSS layer.
answer
.addClass('linked')
.animate({
backgroundColor: originalBackgroundColor
}, 1000);
// You may optionally remove the added class
// in the callback of the above animation.
}

alex
- 479,566
- 201
- 878
- 984