A Pen by Ben Grosser on CodePen.
Created
March 1, 2016 22:39
-
-
Save bengrosser/fad5fac874c269161a87 to your computer and use it in GitHub Desktop.
aNzrwm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form method="get" id="search"> | |
<input type="text" class="searchbox" value="Search Wikipedia..." onblur="if(this.value == '') { this.value = 'Search Wikipedia...'; }" onfocus="if(this.value == 'Search Wikipedia...') { this.value = ''; }" name="s"> | |
<button type="submit">Submit</button> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".searchbox").autocomplete({ | |
source: function(request, response) { | |
$.ajax({ | |
url: "http://en.wikipedia.org/w/api.php", | |
dataType: "jsonp", | |
data: { | |
'action': "opensearch", | |
'format': "json", | |
'search': request.term | |
}, | |
success: function(data) { | |
response(data[1]); | |
} | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment