If I have for example several <span>
and I click on one as I can, with jquery to know which one I clicked on? Are the IDs of the elements numbered automatically with item_<?php echo $i; ?>
?
That is to say, I want that when doing in the span with id=item_2
it makes me for example a alert.()
"you have clicked on item_2"
<div id="items_en_uso">
<span style="background:#c9c9c9;padding:3px;" id="item_1">Hola</span><br><br>
<span style="background:#c9c9c9;padding:3px;" id="item_2">adios</span><br><br>
<span style="background:#c9c9c9;padding:3px;" id="item_3">buenas</span><br><br>
<span style="background:#c9c9c9;padding:3px;" id="item_4">malas</span><br><br>
</div>
EDIT:
Spans are added by clicking on another item with
$("#clikeable").click(function(){
$("#items_en_uso").append("<span id='item"+count+"'>Hola</span>");
});
If the spans are placed by hand (not by jquery) if that works, but if I add them with jquery when I click them, it does not work ... How can I fix this?