see response at the original thread:

http://groups.google.com/group/jquery-en/browse_thread/thread/37906be6845780c2?hl=en

On Nov 16, 1:43 pm, bob <[EMAIL PROTECTED]> wrote:
> Is it possible to iterate over the array and create functions as
> follows?
> It did not seem to work for me.
>
> var menu = ['home','news','sport','music'];
>
> for(var i=0; i<menu.length;i++) {
>
>         $('#'+menu[i]+'_header').click(function(){ alert(i);
>                 alert(menu[i]+'_header clicked');
>
>                 var $img = $(this).find('img');
>                 var src = $img.attr('src');
>                 var newsrc = /up\.gif$/.test(src) ? src.replace
> ('up','down') :
> src.replace('down','up');
>                 $img.attr('src',newsrc);
>
>         });
>
> }

Reply via email to