Hey everyone,
I just got a solution from here, but I think I spoke to soon, as I ran into another problem right away. I have been playing around with it for a couple days now, and just hoping that someone could explain or see why it isn't working.

I want to make a call to a dynamic element like so... $("#"+item_b).remove(); But it doesn't work, I put the entire code below for reference.

Here is a snippet of the code:

var img = $('<img>').attr({
      src: fileObj.filePath,
      alt: fileObj.name
      }).css({
      height: "100px",
      margin: "0 5px"
      });
      var txt = $('<span>').html(fileObj.name + ' uploaded.');
      var link = $('<a>')
      .attr({ href: '' })
      .text('Upload Different Image')
      .click(function(f){
      return function(){
      del_image(f.filePath,f.name);
      return false;};
	  }(fileObj));//call immediately forming closure to capture current fileObj attributes
	  
	  $('preview_logo').append('<div id=\"'+fileObj.name+'\"></div>'); //The div does get created
$('#'+fileObj.name).append(img).append(txt).append(link);/>'); //but this doesn't get put in the div

And the function:

function del_image(item_a, item_b){
	$("#logo_upUploader").show(); 
	$("#uploadifyUp").show();
	//$('div').remove("#"+item_b);
	$("#"+item_b).remove();
		$.ajax({
    type: "POST",
    url: "plugin/delete_image.php",
    data: "filepath="+item_a,
    success: function(){
    alert( item_b+" Deleted");
}
});
}

Thanks for any help at all,

Take care

Ok so finally, after a ton of variations I got it to work.
Instead of this... $("#"+item_b).remove(); This works though... $("div[id='" +item_b+ "']").remove(); I also tried a few variations of the following (change the quotes) $("#' +fname+ '") without success.

Would this be because of the variable I'm using for the selector or am I doing somehting dumb with quotes,

Thanks,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.