# Clearing previous results in Wikipedia Viewer

**URL:** <https://forum.freecodecamp.org/t/clearing-previous-results-in-wikipedia-viewer/136452>\
**Category:** General\
**Created:** [July 16, 2017, 6:25am UTC](https://forum.freecodecamp.org/t/clearing-previous-results-in-wikipedia-viewer/136452 "2017-07-16T06:25:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Embustero](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/embustero/32/48891_2.png) [@Embustero](https://forum.freecodecamp.org/u/Embustero)\
**Post date:** [July 16, 2017, 6:25am UTC](https://forum.freecodecamp.org/t/clearing-previous-results-in-wikipedia-viewer/136452/1 "2017-07-16T06:25:06Z")

</div>

I’ve mostly completed the Wikipedia Viewer project but have not figured out how to clear all previous search results after I search for a new word. I know that I have to use the .empty() command, but I can’t figure out where to place it. I would appreciate it if someone could take a look at my code and tell me how to fix this issue: [https://codepen.io/Crimson\_Macaw/pen/weNWEa](https://codepen.io/Crimson_Macaw/pen/weNWEa)

---

<div class="post-metadata">

**Author:** ![DaveC](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/davec/32/161518_2.png) [@DaveC](https://forum.freecodecamp.org/u/DaveC)\
**Post date:** [July 16, 2017, 6:29am UTC](https://forum.freecodecamp.org/t/clearing-previous-results-in-wikipedia-viewer/136452/2 "2017-07-16T06:29:08Z")

</div>

In your case, right above the loop:

```auto
$("#searchList").empty();
for (var i = 0; i < link.length; i++){
// your other code
}

```

---

<div class="post-metadata">

**Author:** ![Embustero](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/embustero/32/48891_2.png) [@Embustero](https://forum.freecodecamp.org/u/Embustero)\
**Post date:** [July 16, 2017, 8:35am UTC](https://forum.freecodecamp.org/t/clearing-previous-results-in-wikipedia-viewer/136452/3 "2017-07-16T08:35:02Z")

</div>

Thanks Dave, I thought I had tried placing the .empty() command almost everywhere, but obviously did not try placing it above the loop.

---

<div class="post-metadata">

**Author:** ![anon52159105](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@anon52159105](https://forum.freecodecamp.org/u/anon52159105)\
**Post date:** [July 16, 2017, 10:29am UTC](https://forum.freecodecamp.org/t/clearing-previous-results-in-wikipedia-viewer/136452/4 "2017-07-16T10:29:28Z")

</div>

My loop created a big string of HTML, I only needed to overwrite the HTML of a DIV each time, no empty process needed.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:48pm UTC](https://forum.freecodecamp.org/t/clearing-previous-results-in-wikipedia-viewer/136452/5 "2021-01-17T20:48:02Z")

</div>

Closed on January 17, 2021, 8:48pm UTC


