简体   繁体   中英

$(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();

函数应具有两个参数:

function(index,next)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM