html.replace() is a string, not a jquery object. I'm guessing (since you didn't post the code with the find
and you stated that you added .find
after replace) that you were doing this:
html = $(html.replace(/<img[^>]*>/g,"").find("#specialDiv"));
if that is the case, just move the find outside:
html = $(html.replace(/<img[^>]*>/g,"")).find("#specialDiv");
also, there really is no need to modify the dom as a string... nor do you need to worry about removing tags from content you don't care about... this would be better:
html = $(html).find("#specialDiv");
html.find("img").remove();
http://jsfiddle.net/S8zxQ/