JQuery remove () to remove object by variable

I am trying to do something like this:

var rowResult = $(template(data)).find(".progressBar").progressbar({ value : 0 }).end();
this.jQueryDialog.find("ul#filesList").append(rowResult); 

$(rowResult).on("click", "button.removeButton", function()  { 
       $("ul#filesList").remove(rowResult);
 });

      

Why does append () work but remove () throws a type error ?:

TypeError: expr.replace is not a function
Line: expr = expr.replace(rattributeQuotes, "='$1']" );     jquery.js

      

+3


source to share


3 answers


try it



$(rowResult).on("click", "button.removeButton", function()  { 
       $(rowResult, "ul#filesList").remove();
});

      

+7


source


I don't think remove takes any arguments.



try $ ("ul # filesList"). remove ();

+4


source


Works like a charm:

$(rowResult).on("click", "button.removeButton", function()  { 
   $(this).remove();
});

      

I used to avoid using "this" in JS, but once you know how to use it correctly it can be very helpful.

0


source







All Articles