Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8924705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:29:23+00:00 2026-06-15T07:29:23+00:00

My code looks like this: quickbarcolor = $(#quick-bar a).css(color); $(#quick-bar a).hover(function () { if

  • 0

My code looks like this:

quickbarcolor = $("#quick-bar a").css("color");
$("#quick-bar a").hover(function () {
  if ($(this).css("color") != quickbarcolor) quickbarcolorhover = $(this).css("color");
 V$(this).animate({ color: quickbarcolorhover },400);
}, function() {
  $(this).animate({ 'color': quickbarcolor},400)}  
);

It works fine but it depends on global variables to share the colors between the two functions in hover(). I don’t know everything about global vars but I thought it was better to avoid them unless necessary, though I know that sharing values between functions is what they are for. Still I’d like to see if anyone knows a better way of doing this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:29:25+00:00Added an answer on June 15, 2026 at 7:29 am

    One option is to store your values on the DOM element being animated using the data-* attribute. Here’s what I mean by that:

    $.data($("#quick-bar a"), "col", $("#quick-bar a").css("color"));
    
    $("#quick-bar a").hover(function() {
        var self = $(this);
        var col = $.data(self, "col");
        if ($(this).css("color") != col) {
             $.data(self, "col", self.css("color"));
        }
    
        self.animate({
            color: col
        }, 400);
    
        $.data(self, "col", self.css("color");
    }, function() {
        $(this).animate({
            'color':  $.data($(this), "col");
        }, 400)
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code looks like this: css: .top { position: absolute; top:0; left:0; height: 1600px;
My helper code looks like this (and works fine btw): module ProvidersHelper def call_to_review(provider)
Right now my code looks like this: <script type=text/javascript> $(document).ready(function() { $.ajaxSetup({ cache: false
The code looks like this function Scripts() {this.FindById = function (id) { this.FindById.constructor.prototype.value =
the code looks like this function new_excerpt_length($length) { return 100; } add_filter('excerpt_length', 'new_excerpt_length'); there
My code looks like this, and it works: if Target.find_by_shrunk(params[:shrunk]) @target = Target.find_by_shrunk(params[:shrunk]) else
The original code looks like this,it works. def my_index(request): global account if request.session.get('account',False): account=request.session['account']
The code looks like this: <body> <div id='1'> <div id='2'> </div> </div> css: #1
My code looks like this: $.get('http://files.mysite.com/data.json', function(data) { console.log(data); }, jsonp); When I take
My jquery code looks like this: $(document).ready(function() { $('.French').click(function(){ changeBackground(); }); }); function changeBackground(){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.