Clearing previous results in Wikipedia Viewer

Clearing previous results in Wikipedia Viewer


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:


In your case, right above the loop:

for (var i = 0; i < link.length; i++){
// your other code


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


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