Gautam
Gautam

Reputation: 1740

$(selector).each() function not working

I am using the following function in my jquery code

$('#columns').each(function (index) {
alert('here');
});

I am pretty much sure that I have a div with Id columns in my aspx code, but the issue is that this loop is not getting executed while running the code. not only this.. I have a few other .each loops in my code but none of them are working. any help with this?

even if I use

$('p').each(function (index) { ....

or

$('div').each(function (index) { ....

or

$('.column').each(function (index) { ....

still it wont work.

UPDATE: Following is the structure of my jquery

var iWidget = {

    jQuery: $,

    settings: {....},
...Code goes here
init: function () {

        this.func1();
        this.func2();
    },....
}
.
iWidget.init();

Upvotes: 1

Views: 510

Answers (2)

Sibi
Sibi

Reputation: 48644

Function should have two parameters:

function(index,next)

Upvotes: 2

Santosh
Santosh

Reputation: 1261

Because you are adding 'each' method on the id element. Not on class element.

Upvotes: -1

Related Questions