test
test

Reputation: 18198

jQuery function string

This isn't working:

function checkIt(String rep) {
         if (counter[$(rep).val()] == undefined) {
         count++;
         result = Math.round((count * 100 )/howMany);
         $('.percent').text(result);
         $('#perc_in').animate({'width': result+'%'}, 500);
         counter[$(this).val()] = 1;
         $('#counter').text(result);
         }
}

Like, at all... <_< I mean I think I am doing the function wrong.

Then inside the case statement I have this:

checkIt($(this).val());

Upvotes: 0

Views: 172

Answers (1)

Yi Jiang
Yi Jiang

Reputation: 50115

Javascript is weak typed, so what in the world is this?

function checkIt(String rep) {

Just change it to

function checkIt(rep) {

It's also a bit odd that you are try to create a new jQuery object from the value of another form element. And this line:

if (counter[$(rep).val()] == undefined) {

This may be a little dangerous if you're just checking for the non-existence of an array element, since $(rep).val() could also be undefined depending on the situation.

Upvotes: 3

Related Questions