Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lobster&display=swap" rel="stylesheet">
<div class="container">
    <div class="text-center">
        <h1 class="title">Wikipedia API Search</h1>
        <h4>FCC Front End Development</h4>
        <a href="https://en.wikipedia.org/wiki/Special:Random" target="_blank">
            <img src="https://cdn-icons-png.flaticon.com/512/49/49360.png" alt="wikipedia icon" width=200px height=200px>
        </a>
    </div>
    <div id="SearchBox">
        <input type="text" class="from-control" id="searchTerm" width=500px>
        <button id="search" type="button" class="btn btn-primary">SUBMIT</button>

        <ul id="output">

        </ul>
    </div>
</div>
              
            
!

CSS

              
                h1,
h4 {
    color: blue;
}
body {
    background-image: url("https://images.pexels.com/photos/1856422/pexels-photo-1856422.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1");

    font-family: "lobster", Times New Roman;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
}
#searchTerm {
    margin-left: 30%;
    margin-right: 30%;
    margin-top: 5px;
}
#SearchBox {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    align-content: center;
}
.btn {
    border: 0;
    outline: 0;
    color: #333;
    padding: 5px;
    font-size: 14px;
    cursor: pointer;
    min-width: 120px;
    margin: 15px 5px;
    min-height: 20px;
    font-weight: 700;
    line-height: 30px;
    text-align: center;
    border-radius: 5px;
    text-decoration: none;
    background-color: #fff;
    font-family: monospace;
    border-bottom: 4px solid #d9d9d9;
    box-shadow: 0px 5px 10px #333;
    -webkit-transition: all 0.3s;
    transition: all 0.3s;
}

.btn:active {
    box-shadow: 0px 4px 8px #333;
    -webkit-transform: scale(0.98);
    transform: scale(0.98);
}

              
            
!

JS

              
                //start jquery
$(document).ready(function () {
    //when search is clicked run code
    $("#search").click(function () {
        //Gets the search input
        var searchTerm = $("#searchTerm").val();
        //API url with searchTerm
        var url =
            "https://en.wikipedia.org/w/api.php?action=opensearch&search=" +
            searchTerm +
            "&format=json&callback=?";
        $.ajax({
            type: "GET",
            url: url,
            async: true,
            dataType: "json",
            success: function (data) {
                //get heading
                //console.log(data[1][0]);
                //get description
                //console.log(data[2][0]);
                //get link
                //console.log(data[3][0]);
                $("#output").html("");
                for (var i = 0; i < data[1].length; i++) {
                    $("#output").prepend(
                        "<li><a href= " +
                            data[3][i] +
                            ">" +
                            data[1][i] +
                            "</a><p>" +
                            data[2][i] +
                            "</p></li>"
                    );
                }
                $("#searchTerm").val("");
            },
            error: function (errorMessage) {
                alert("Error");
            }
        });
    });
    $("#searchTerm").keypress(function (e) {
        if (e.which == 13) {
            $("#search").click();
        }
    });
});

              
            
!
999px

Console