user2426701
user2426701

Reputation:

Clone, clear input and html

I have this simple snippet of code below to clone some html code. As you can see it clears all the inputs.

The problem is that I have also to clear all the spans. I tried to add another .find searching for spans and clearing the HTML. But obviously after the first .find it does look into inputs and does not find any span. How can I edit the blow code in order to clean also all the spans in addition to inputs ?

$('#addBox').clone(false).find("input").val('').end().appendTo('#append');

Upvotes: 0

Views: 96

Answers (1)

J0HN
J0HN

Reputation: 26941

$('#addBox').clone(false).find("input, span").val('').html('').end().appendTo('#append');

See css selectors standard for details (paragraph 5.2.1 Grouping)

Upvotes: 1

Related Questions