I tried changing the HTML/Javascript to this: $("#select option").each(function(){ var value = $(this).html(); $(this).addClass(value); $('.foo').append('<a href="#"><img src="' + value + '.gif" class="' + value + '" alt="' + value + '" /></a>'); }); $('.foo a img').click(function(event){ event.preventDefault(); var fAlt = $('.foo a img').attr('alt'); $('.fooAlt').text(fAlt) })
<select id="select"> <option value="1">1 test</option> <option value="2">2 test</option> <option value="3">3 test</option> </select> <div class="test_area"> <div class="foo"></div> <div class="fooAlt"></div> </div> And it is still not working: I am filling the div with a select menu: is that the problem?