Skip to content
Advertisement

jQuery loop append result after every event

I apply each loop in jQuery with onchange() event.

JavaScript

So my problem is when I select option(“RAW”) it return result as option values and then I select “DEPTH” option and it add “RAW” and “DEPTH” return result and give both data as option.

output – when I select “RAW”

JavaScript

When I select “DEPTH”

JavaScript

So I want, when I select option it return loop data and when again select option then it return new loop data not append data with previous select.

Output should like this- When I select “DEPTH” option after “RAW” option so it return

JavaScript

But it does not return that result.

Advertisement

Answer

You are appending the new data instead of replacing old one with it. Instead of append use html

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement