for (var i in folders) { var b = '#f'+i; alert (b); $(b).bind('click', function() { alert (b); }); }
Try this instead: for (var i in folders) { $('#f'+i).bind('click', function() { alert ($(this).attr("id")); }); } On Apr 21, 9:08 am, wyo <[EMAIL PROTECTED]> wrote: > On 21 Apr., 14:52, Giant Jam Sandwich <[EMAIL PROTECTED]> wrote:> Unless you > need the unique ID for each paragraph, it might be easier > > to bind the click by the class name. jQuery will perform the foreach > > logic for you. > > Well depending on which folder is clicked I'd like to switch to a > certain picture, therefore I need each folder separately. > > O. Wyss