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");
});
});