cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <body>
<h1>Wikipedia Viewer</h1>	 
<p>
<a href="https://en.wikipedia.org/wiki/Special:Random">Random article: Take a Chance</a><br>

<form id="form" onsubmit="return search()">
	<input id="find" type="search">
	<input id="searchBtn" type="submit" value="Search">
  </form>
  
<img src="http://calvarycentraloahu.com/codepen/wiki_logo.png" alt="wikipedia icon">
  
<div id="display"></div>
</body>
            
          
!
            
              body { 
  margin-top: 20px;
  background: #000;
  font-family: "arial", tahoma
}

h1, h2, h3 {
  text-align: center;
  color: #54a6f2;
}

a {
  font-size: medium;
  color: #54a6f2;
  text-align:center;
  display:block; 
}

#form {
	font-size: 24px;
	margin: 20px 0 40px 0;
	color: #2E7D32;
	text-align:center;
}

#find {
	width: 350px;
	padding: 10px;
	height: 42px;
	background: #fff;
	border: 3px solid #9b9292;	
}

#search {
	height: 42px;
	width: 120px;
	background: #99d2ef;
	border: 3px solid #9b9292;	
	margin-left: -2px;
}

#searchBtn {
	height: 42px;
	width: 120px;
	background: #94ccef;
	border: 3px solid #a5a2a2;
	margin-left: -2px;
}

img {
    display: block;
    margin: 0 auto;
}

/* display results css  */
.result {
	background: #938c8c;
	box-shadow: 0 0 6px 2px rgba(0,0,0,.12);
  color: #000;
	margin: 24px 0;
	padding: 16px;
}

.title {
	font-weight: bold;
	font-size: 28px;
}
.text {
	font-size: 18px;
}


            
          
!
            
              //https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
$('#form').submit(function(e){
	e.preventDefault();
  //Cancels the event if it is cancelable, without stopping further propagation of the event.
});

function search(){
$("#display").empty();
sq = $('#find').val();
//sq = Squares a number (multiplies a number by itself). The result is always a positive number, as multiplying two negative numbers always yields a positive result.   
  
//wikipedia API
$.getJSON("https://en.wikipedia.org/w/api.php?action=query&list=search&format=json&srsearch="+sq+"&srnamespace=0&srwhat=text&titles=Main%20Page&callback=?", function(d) {

$.each(d.query.search, function(i, item){
//display property show results			
var wiki = '<div class="result">'+
	'<div class="title">'+item.title+'</div>'+
	'<div class="text">'+item.snippet+'</div></div>';
			$("#display").append(wiki);
		});
	});
$('#find').val('');
}

            
          
!
999px
Loading ..................

Console