changing to class will do what you need

here's an example using live() instead of livequery since it is built into jquery now and works for click function you are using

I just changed to a UL instead of images
http://jsbin.com/ewutu


fabrice.regnier wrote:
hi ;)

  
An id must be unique on a page. In your code, every created image as the
same id maybe the problem is here but i'm not sure.
    
Yes, i guess, this is the problem.

  
I think the first step is to replace id with a class and see if it works.
    
Can you give some exemple ?

The probleme is: i want to remove, let's say, the 4th image, by
clicking on it. I don't see where class can help me. I surely must use
some kind of array but in which way ?

regards,

f.


  
You can use the live event gestion if you use jquery > 1.3 (http://docs.jquery.com/Events/live)
Pierre

2009/6/12 fabrice.regnier <fabrice.regn...@gmail.com>



    
Hi all,
      
When i click once on a button, i create one picture on the fly. And so
on. It works ok.
      
Then, using livequery, when i click on one of the all created
pictures, i would like to see it removed. But it appears that only the
first pic is removed (since all have the same name).
      
What is my mistake ?
      
regards,
      
f.
      
<JQUERY>
      
$("#IdButton").click( function() {
 var pic="<p><img id=\"IdPicture\" name=\"IdPicture[]\" src=""
images/icone_ko_small.png\"/></p>"
 $(this).before(pic);
});
      
$("#IdPicture").livequery('click', function(event) {
   $(this).remove();
});
      
<HTML>
      
<input type="submit" id="IdButton" class="button">
      

  

Reply via email to