I have this code which can be seen Here. The idea would be that I could have a list of items, which I could then assign a handler to run whatever repetitive code I would need to run (for example, a function which modifies a series of classes). The idea is that I could iterate through a list of ids and assign a handler, however due to my limited knowledge of Javascript, it doesn't' appear to be working. Would anyone be able to help?
The Code of Interest:
HTML:
<a href="#" id="first">First</a><br>
<a href="#" id="second">Second</a><br>
<a href="#" id="third">Third</a><br>
<a href="#" id="forth">Forth</a><br>
Javascript:
//Choose which ids I want to iterate
ids = ['#first', '#second', '#third', 'forth']
//For all the ids there are
for ( i=0; i<ids.length; i++ ) {
    //Select an item
    item = ids[i]
    //Add a click handler to that item
    $( item ).click(function() {
          //Run a function that involves knowing the item I have iterated...
          alert( "Handler for "+ item + " called." );
    });
}
Thanks,
Aj.
 
     
    