jQuery UI 是一个基于 jQuery 的用户界面库,它提供了一系列的交互组件和效果,用于创建丰富且可访问的 Web 应用程序。jQuery UI 的设计理念是“简约”,即通过简单的 API 和少量的代码实现复杂的功能。
以下是一个简单的示例,展示如何使用 jQuery UI 创建一个按钮和一个对话框:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery UI Example</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script>
$(function() {
$("#dialog").dialog({
autoOpen: false,
modal: true,
buttons: {
"OK": function() {
$(this).dialog("close");
}
}
});
$("#openDialog").click(function() {
$("#dialog").dialog("open");
});
});
</script>
</head>
<body>
<button id="openDialog">Open Dialog</button>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</body>
</html>通过以上信息,你应该能够更好地理解和应用 jQuery UI 来创建简约且功能丰富的用户界面。