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

  • SEARCH
  • Home
  • 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 3622602
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:16:49+00:00 2026-05-18T23:16:49+00:00

I have this global variable which is used as counter which I want to

  • 0

I have this global variable which is used as counter which I want to access in the jquery hover function. But some how the variable is throwing “undefined” error when I try to access it in the hover function. The code is

var i = 0

$('#ticker-area').hover(function() {
    alert(i); //THROWS UNDEFINED ERROR  
    clearTimeout(t1);   
    if (i > 0) {  
        alert(i); //NEVER REACHES HERE  
        var i = i - 1;  
        var innerText = tickerItems[i];  
        i++;  
    }  
    $('#ticker-area').html(innerText);  
}, function() {  
    clearTimeout(t1);  
    rotateTicker();  
});  

Please help.
Thanks
Paddy

  • 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-05-18T23:16:50+00:00Added an answer on May 18, 2026 at 11:16 pm

    If you are new to javascript always use http://www.jslint.com/ to check your code.

    Checking your code I get the following errors:

    Problem at line 1 character 10: Missing semicolon.
    
    var i = 0
    
    Problem at line 8 character 15: 'i' is already defined.
    
    var i = i - 1;
    
    Problem at line 12 character 28: 'innerText' used out of scope.
    
    $('#ticker-area').html(innerText); 
    

    So

    1. put a semicolon in line 1
    2. remove the var declaration in line 8
    3. put the var innerText declaration at the begining to make it visible
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a global static variable x like in this code #include <stdio.h>
I have a singleton class for global access to config information. This singleton class
I have this code in jQuery, that I want to reimplement with the prototype
I have a variable which is the head to a linked list. I want
In Actionscript you can have global variables like this: var number : Number =
I have this code public static Boolean freq[] = new Boolean[Global.iParameter[2]]; freq[Global.iParameter[2]] = false;
i have this: Dim split As String() = temp_string.Split(,) ''#feed all info into global
I have a class Application that my global.asax inherits from. The class has this
I have read in many posts that global variables are bad, but I need
I have some ASP.NET web services which all share a common helper class they

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.