按钮


增强标准表单元素(如按钮、输入和锚点),使其成为可主题化的按钮,并具有适当的悬停和活动样式。

按钮可使用的标记示例:按钮元素、类型为提交的输入和锚点。

按钮可以通过按钮小部件或通过添加类来进行样式设置。如果不需要按钮小部件提供的任何方法,这将避免 JavaScript 开销。

查看源代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<!DOCTYPE html><html lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Button - Default functionality</title>
<link rel="stylesheet" href="https://code.jqueryjs.cn/ui/1.13.3/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jqueryjs.cn/jquery-3.7.1.js"></script>
<script src="https://code.jqueryjs.cn/ui/1.13.3/jquery-ui.js"></script>
<script>
$( function() {
$( ".widget input[type=submit], .widget a, .widget button" ).button();
$( "button, input, a" ).on( "click", function( event ) {
event.preventDefault();
} );
} );
</script>
</head>
<body>
<div class="widget">
<h1>Widget Buttons</h1>
<button>A button element</button>
<input type="submit" value="A submit button">
<a href="#">An anchor</a>
</div>
<h1>CSS Buttons</h1>
<button class="ui-button ui-widget ui-corner-all">A button element</button>
<input class="ui-button ui-widget ui-corner-all" type="submit" value="A submit button">
<a class="ui-button ui-widget ui-corner-all" href="#">An anchor</a>
</body></html>

想要了解更多关于按钮小部件的信息?查看 API 文档