Need help for my Wikipedia Viewer

Hello guys. I need help for the wikipedia viewer project.
Basically, I am at this point:
http://theophile.me/wikiviewer/index.html

1- Now, when I search and use the enter button event, it works one time out of three. Why?
2-When I search for something, I want to be able to enter another search item and remove the previous queries. What would you suggest as a method?

Here are my codes:

HTML:

<body>
    <div class="jumbotron jumbotron-fluid">
        <div class="container">
            <h1 class="display-3 text-xs-center"><a href="index.html">Wikipedia Viewer</a></h1>
            <p class="lead text-xs-center">This web app has been created to help you find Wikipedia articles easily</p>
            <div class="row search-form">
            <div class="container">
                <form class="form-inline">
                    <div class="form-group">
                        <div class="input-group">
                            <input type="text" class="form-control search-query" id="searchQuery" placeholder="What are you looking for?">
                            <div class="input-group-addon"><a href="#" class="search-button"><i class="fa fa-search" aria-hidden="true"></i></a></div>
                            <div class="input-group-addon"><a href="https://en.wikipedia.org/wiki/Special:Random"><i class="fa fa-random" aria-hidden="true"></i></a></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        </div>
    </div>
    <div class="container">
        <div class="row main-content">
        </div>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src="js/viewer.js"></script>
</body>

As for the JS file:
http://theophile.me/wikiviewer/js/viewer.js

Thanks in advance.

1 Like

Try adding e.preventDefault() before showContent() in the keyup.

1 Like

I just fixed this error. Adding the preventDefault() so it wont reload page when button is clicked