Does this code really make sense, even in jQuery?
Code:
$(function () {
var textBox1 = $('input:text[id$=Box1]').keyup(AddItUp);
var textBox2 = $('input:text[id$=Box2]').keyup(AddItUp);
var textBox3 = $('input:text[id$=Box3]').keyup(AddItUp);
var textBox4 = $('input:text[id$=Box4]').keyup(AddItUp);
var textBox5 = $('input:text[id$=Box5]').keyup(AddItUp);
var textBox6 = $('input:text[id$=Box6]').keyup(AddItUp);
???
Seems to me like that is assigning the result of calling keyup to the six vars.
Shouldn't all those lines be more like
Code:
var textBox1,textBox2,textBox3,textBox4,textBox5,textBox6;
( textBox1 = $('input:text[id$=Box1]') ).keyup(AddItUp);
etc.
And is there really any reason to use
$('input:text[id$=Box1]')???
What's wrong with simply
$("#Box1")?
But now why do it like that, at all?
Code:
$(function () {
var boxes = [];
for ( var b = 1; b <= 6; ++b )
{
boxes[b] = $("#Box"+b);
boxes[b].keyup(AddItUp);
}
Though for the life of me I can't see any reason to drag in the entire jQuery library for this simple stuff.