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. 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

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

              
                <body>
  <div class='container container-fluid head1'>
    <h1>Wikipedia</h1>
    <h2><a id="Random" href="http://en.wikipedia.org/wiki/Special:Randompage" target="_blank">Random Article</a></h2>
   
      Search:<br>
      <form>
      <input id="variable1"type="text"><br><br>
      
      <button id="go" >submit</button>
        <h2>Search response</h2>
    
   </form>
  </div>
<br><br>

  <div class='container container-fluid' id='containerList'></div>
  
  
  


</body>
              
            
!

CSS

              
                 html
  {
    overflow:scroll;	
  }

.head1{
  text-align:center;
}


#containerList{
  
  text-align:center;
  width:50em;
  
  
}
.test2{
  
  background:grey;
  padding:1em;
  margin:1em;
  
}

a{
  color:black;
  
 
}

#Random{
  text-decoration: none;
  
}

#Random:hover{
  color:grey;
}

#responseTag:hover{
  color:white;
}


              
            
!

JS

              
                $(document).ready(function() {

  var value1;

  $("#variable1").on("keyup change", function() {
    value1 = this.value; // omit "var" to make it global
    $("#dom_element").text(value1);

    if (event.keyCode == 13) {
      $("#go").click();
    }

  });

  //var inputValue;
  $("form").submit(function() {

    event.preventDefault();

    $(".test2").remove();
    //value1 = "apple";

    var camperApi = "http://en.wikipedia.org//w/api.php?action=query&format=json&prop=info&list=search&indexpageids=1&formatversion=2&inprop=url%7Csubjectid&srsearch=" + value1 + "&srinfo=&srprop=sectiontitle&callback=?";

    console.log(value1);

    $.getJSON(camperApi, function(json) {

      console.log(json);
      for (var c in json.query.search) {
        //this first block creates the html elements
        var TiTle = json.query.search[c].title;

        var newElement = document.createElement('div');
        var aTag = document.createElement('a');
      
          
        var serDiv = document.createElement('h4');
        var link = "https://en.wikipedia.org/wiki/" + TiTle;
        //this block assigns json data to variables

        
        serDiv.innerHTML = json.query.search[c].title;

        //this block gives html elements class names and assigns href values
        newElement.className = 'test2';
        serDiv.className = 'serDiv';
        aTag.href = link;
        aTag.id= 'responseTag';
        

        //this block sends all the information to the html    
        document.getElementById('containerList').appendChild(newElement);
        newElement.appendChild(aTag);
        aTag.appendChild(serDiv);
        
        
        
        
      }

      // console.log(json);
      //iterate through the json and pull the needed information and send that to html.

      // });

    });

    //var inputValue = $('#yourInputId').val();
    //console.log(inputValue);
    //var inputValue="orange";

  });

});
              
            
!
999px

Console