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 1049985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:42:04+00:00 2026-05-16T16:42:04+00:00

Ok, before you review the code below, I know that it is AWFUL. It’s

  • 0

Ok, before you review the code below, I know that it is AWFUL. It’s redundant and bloated and I am not asking for anyone to fix it 🙂

I am wondering what I need to study in order to fix it on my own. I’m working on a small project for my daughter, an interactive multiplication table that she can view in Mobile Safari.

I want to highlight the cells that lead to a selected number. So, I created this and I’m sharing it because I want to improve it, but I don’t have enough knowledge yet.

What principles do I need to study to improve this kind of functionality?

You can see the whole thing here: http://dandenney.com/dev/jasmultiplication

The 100 (10 x 10) is an example of what I am trying to achieve, but I want to do it for every number:

// This starts base functionality of highlighting the involved numbers, 10x10=100
$(document).ready(function() {
    $(".tenxten").hover(function () {
            $("td").addClass("non-choice");
            }, function () {
            $("td").removeClass("non-choice");
    });
    $(".tenxten").hover(function () {
            $(".twoxten, .threexten, .fourxten, .fivexten, .sixxten, .sevenxten,  .eightxten, .ninexten").addClass("vertical-trail");
            }, function () {
            $(".twoxten, .threexten, .fourxten, .fivexten, .sixxten, .sevenxten, .eightxten, .ninexten").removeClass("vertical-trail");
    });
    $(".tenxten").hover(function () {
            $(".tenxtwo, .tenxthree, .tenxfour, .tenxfive, .tenxsix, .tenxseven, .tenxeight, .tenxnine").addClass("horizontal-trail");
            }, function () {
            $(".tenxtwo, .tenxthree, .tenxfour, .tenxfive, .tenxsix, .tenxseven, .tenxeight, .tenxnine").removeClass("horizontal-trail");
    });
    $(".tenxten").hover(function () {
            $(".vertical-ten, .horizontal-ten").addClass("choice");
            }, function () {
            $(".vertical-ten, .horizontal-ten").removeClass("choice");
    });
});                
  • 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-16T16:42:05+00:00Added an answer on May 16, 2026 at 4:42 pm

    To get the 10×10 effect you can use the row you’re hovering, the index of the <td> in it, and .prevAll() for both to get the effect on the right cells, like this:

    $(function() {
      $("#multiplication").delegate("tr:gt(0) td:not(:first-child)", "hover", function() {
        $(this).toggleClass("choice").prevAll().toggleClass("horizontal-trail")
         .end().closest('tr').prevAll().find('td:nth-child('+($(this).index()+1)+')')
                                       .toggleClass('vertical-trail');
      });
    });
    

    You can give it a try here, this applies the horizontal class by just using .prevAll() to get the previous cells in the row. Then using .end() we go back to $(this) (the currently hovered cell), go up to it’s <tr> using .closest(), again get all rows before that using .prevAll() and getting the cells at the same index in them using .find() and :nth-child(), then adding or removing the class on those cells.

    Since you’re just toggling on and off, you can use one hover function which maps to both mouseneter and mouseleave combined with .toggleClass(). The .delegate() use is to have one hover handler here, instead of 100.

    The initial selector "tr:gt(0) td:not(:first-child)" is saying not the first row, and not the left most cells in other rows, so this prevents the main numbers from executing this function, so it’ll only happen in the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw some code as below during a peer-code-review session: char *s = new
Before I start, I know there is this post and it doesn't answer my
Before I jump headlong into C#... I've always felt that C, or maybe C++,
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
Before you start firing at me, I'm NOT looking to do this, but someone
This came up as one of the code review comments. Is it a good
I've been using maven for a while, and I often review repositories before selected
Before you answer this I have never developed anything popular enough to attain high
Before I do this I figured I would ask if it was the best
Before, I have found the Cost in the execution plan to be a good

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.