Using Jquery, call function on selection just once
Posted
by maxp
on Stack Overflow
See other posts from Stack Overflow
or by maxp
Published on 2010-06-16T10:21:58Z
Indexed on
2010/06/16
10:32 UTC
Read the original article
Hit count: 260
JavaScript
|jQuery
Say i have a selection of textboxes like this;
var arrayoftextboxes = $('.textbox1, .textbox2, .textbox3');
Is there a way I can call a function on each one in a simpler way than this? It only needs to be called once.
arrayoftextboxes.each(function(i){foo(arrayoftextboxes[i]);});
I tried
arrayoftextboxes.load(function(){foo(this)});
and
arrayoftextboxes.bind(function(){foo(this)});
but the functions dont seem to be called.
© Stack Overflow or respective owner