Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

jQuery UIのオートコンプリート機能

ソースコード

「jquery-ui.js」をインクルードする必要があります。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<label for="month">月選択</label>
<input id="month" type="text" name="month" />
</body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.js"></script>
<script type="text/javascript">
(function ($) {
	$(document).ready(function () {
		var months = [
			'January', 'February', 'March', 'April', 'May', 'June',
			'July', 'August', 'September', 'October', 'November', 'December'];

		$("#month").autocomplete({ source: months });
	});
})(jQuery);
</script>
</html>

動作