Mr_Green
Mr_Green

Reputation: 41822

object is not a function in jquery

In my jquery, I am getting error

Uncaught TypeError: object is not a function


Here is the code:

var localValues = new Array('txtA', 'txtB', 'txtC');
for (var intCount = 0; intCount < localValues.length; intCount++) {
    var control = $('#' + localValues(intCount));  /* ERROR */
    validationOfControls(control);
}   

function validationOfControls(control) {
  // code here
}

It seems to be silly mistake, but I cant figure it out..

Can you please explain what I am doing wrong here?

Upvotes: 1

Views: 103

Answers (1)

Cerbrus
Cerbrus

Reputation: 72849

Replace:

localValues(intCount)

With:

localValues[intCount]

The round brackets () are used for function execution. Square brackets [] are used for array/object access.

Upvotes: 7

Related Questions