前面介紹了 jQuery 的基本用法,jQuery UI 是一套 JavaScript 函式庫,提供抽象化、可自訂主題的 GUI 控制項與動畫效果。基於 jQuery JavaScript 函式庫,可用來建構互動式的 Web 應用。
它的基本功能有:
jQuery UI 的所有控制項都能自訂主題樣式。
下圖為使用 jQuery UI 一些 UI 組件
後面的例子,我們依然是 visual studio 作為開發 IDE,從 http://jqueryui.com 現在最新版的 jQuery 庫,並支持的主題,創建一個 jQueryUIDemo 項目:
scripts 目錄存放 jquery core, jquery ui 庫文件, themes 目錄存放jQuery 自帶的主題,你可以選擇你喜歡的主題,本教程使用其中的「trontastic」主題。創建一個預設的 Default.html 作為測試頁面,如下定義:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Demos</title>
<link rel="stylesheet" href="themes/trontastic/jquery-ui.css" />
<script src="scripts/jquery-1.9.1.js"></script>
<script src="scripts/jquery-ui-1.10.1.custom.js"></script>
<script>
$(function () {
});
</script>
</head>
<body>
</body>
</html>
其中 指明使用的主題,後面引用 jQuery core, jQuery UI 庫。