javascript - how to remove images and span dynamcially? -


i uploading images span text dynamically inside div.after trying remove specific uploaded images span text using below code,

 var images = document.getelementsbyclassname('imgclass');     (var j = 0, leng = images.length; j < leng; j++) {         images[j].onclick = removeimage;     }  function removeimage() {           alert("here");         // var imagename = $(this).attr("src");         // alert(imagename);          $(this).remove();          $(this).find('span').remove();         //$(this).siblings().remove();          var factor = 2;      } 

my problem is, image removing fine span under image not removing.

here problem : http://jsfiddle.net/manivasagam/72cr4bvk/39/

tell me how solve fix?

as adding img , span new created div, can delete whole div:

$(this).closest('div').remove(); 

jsfiddle demo.


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -