title: Jquery Onclick Event function not working 2nd time
body: <p>This is the function I'm using to add an Image and a close button(with the event listener)</p>
  
  <pre><code>function loadframe(img, imgid) {
  
      li = '';
      li += '&lt;li&gt;&lt;img src="' + img + '" width="100" height="120" /&gt;&lt;/li&gt;';
      //li +='&lt;a href="javascript:void(0)" onclick="removeajax(\''+img+'\','+imgid+')" &gt;Close&lt;/a&gt;';
      li += '&lt;input type="button"  id="activate' + imgid + '" value="close"&gt;';
  
      document.getElementById('ulimage2').innerHTML += li;
  
  }​              
  </code></pre>
  
  <p>I'm clicking on some images and they are loaded into the preview pane with 
  close button..</p>
  
  <p>I'm calling this function here..
  it contains a function called</p>
  
  <pre><code>$('#activate' + imgid).click(function() {
      //alert(imgid)
      var yoda1 = stage.get("#" + imgid);
      layery.remove(yodaGroup1);
      layery.draw();
  });​
  </code></pre>
  
  <p>Here is the full function..</p>
  
  <pre><code>function initStage1(images, imgid) {
      //    alert(imgid)
      var yodaGroup1 = "yodaGroup1" + imgid;
      yodaGroup1 = new Kinetic.Group({
          x: 100,
          y: 110,
          draggable: true,
          name: imgid
      });
  
      layery.add(yodaGroup1);
      stage.add(layery);
      var yoda1 = new Kinetic.Image({
          image: images.yoda1,
          x: 0,
          y: 0,
          width: 100,
          height: 120,
          id: imgid,
          name: "image",
          detectionType: "Pixel"
      });
  
      $('#activate' + imgid).click(function() {
          //alert(imgid)
          var yoda1 = stage.get("#" + imgid);
          layery.remove(yodaGroup1);
          layery.draw();
      });
  
      yodaGroup1.add(yoda1);
      yodaGroup1.on("dragstart", function() {
  
          yodaGroup1.moveToTop();
          layery.draw();
      });
      yodaGroup1.on("dblclick dbltap", function() {
          layery.remove(yodaGroup1);
          layery.draw();
      });
      yodaGroup1.on("dragend", function() {
          layery.draw();
          yoda1.saveImageData();
      });
      addAnchor(yodaGroup1, 0, 0, "topLeft");
      addAnchor(yodaGroup1, 100, 0, "topRight");
      addAnchor(yodaGroup1, 100, 120, "bottomRight");
      addAnchor(yodaGroup1, 0, 120, "bottomLeft");
  
      stage.draw();
      yoda1.saveImageData();
  }​ 
  </code></pre>
  
  <p>This onclick is working for the last uploded image only..
  or if I add just one image and then remove it..It is working fine..
  If I add more then 1 image it only works for the close button of the last uploded images..
  I'm using kineticjs here for HTML5 canvas functionality</p>