Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <div id="page">
  <div id="random" class="text-center">
<a href="" target="_blank" class="btn btn-default">Click for random Wikipedia article</a>
<div id="search-area" class="text-center">
    <div id="search-bar">
    <input type="text" name="search" id="search" placeholder="Search..." autocomplete="on"/>
    <button type="button" id ="enter" class="glyphicon glyphicon-search"></button>
<div id="search-results">
              @import url('');
body {
  height: 100%;
  width: 100%;
  font: 16px Montserrat;
  background: #FFFFFF url('') no-repeat fixed center;
  background-size: cover;
#page {
  height: 100%;
  width: 100%;
  color: #555555;
  background: rgba(255,255,255,0.5);
#random {
  padding: 5%;
#search-bar {
  position: relative;
  color: white;
input[name=search] {
  width: 50%;
  background: rgba(0,0,0,0.5);
#search-results {
  position: relative;
  background: rgba(255,255,255,0.9);
.result a{
  margin: 1%;
  color: #555555;
  text-decoration: none;
.result:hover {
  background: rgba(200,200,200,0.4);
  color: #555555;
  text-decoration: none;
  // keyup on #enter wasn't working because input is typed in #search, so moved keyup to #search. accidentally discovered one way to do "incremental search"
  $('#search').on('keyup', wiki);
  $('#enter').on('click', wiki);
  // Function Wiki to do Wikipedia search
  function wiki () {
    var search = $('#search').val();
  // api gives an array rather than object.
  var api = ''+search+'&callback=?';
  /*  // api gives an object
    var api = ''+search+'&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&callback=?'; */
  // get Wikipedia API
  $.getJSON(api, function(data) {
    var title;
    var extract;
    var link;
   // (array) nested for loops
    for (i=3;i<data.length;i++){
      for(j=0;j<data[i].length;j++) {
      title = data[1][j];
      extract = data[2][j];
      link = data[3][j];
      $('#search-results').append('<div class="result"><a href="'+link+'" target="_blank"><ul class="list-unstyled"><li><h3>'+title+'</h3><p>'+extract+'</p></li></ul></a></div>');
   /* // (array) .forEach method
    data.forEach(function(value, index) {
      title = value[1];
      extract = value[2];
      link = value[3];
      $('#search-results').append('<div class="result"><a href="'+link+'" target="_blank"><ul class="list-unstyled"><li><h3>'+title+'</h3><p>'+extract+'</p></li></ul></a></div>');
    /* //(object) for method
    for(key in data.query.pages) {
    var grab = data.query.pages[key];
    title = grab.title;
    extract = grab.extract;
    link = ''+grab.pageid;
    var image = ''+grab.pageimage;
    $('#search-results').append('<div class="result"><a href="'+link+'" target="_blank"><ul class="list-unstyled"><li><h3>'+title+'</h3><img src="'+image+'" alt="'+title+'"><p>'+extract+'</p></li></ul></a></div>');
    } */
  }); // close Wikipedia API
  }; // close wiki function
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.