搜索

0

主题

0

帖子

10

积分

新手上路

Rank: 1

积分
10
发表于 2020-9-25 13:40:47 126 浏览 0 回复 来自手机

AmazeUI 按钮交互的实现示例

本文主要介绍了AmazeUI 按钮交互的实现示例,分享给大家,具体如下:

  1. <!doctype html>
  2. <html class="no-js">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="description" content="">
  7. <meta name="keywords" content="">
  8. <meta name="viewport" content="width=device-width, initial-scale=1">
  9. <title>按钮交互</title>
  10. <meta name="renderer" content="webkit">
  11. <meta http-equiv="Cache-Control" content="no-siteapp"/>
  12. <link rel="icon" type="image/png" href="assets/i/favicon.png">
  13. <meta name="mobile-web-app-capable" content="yes">
  14. <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png">
  15. <meta name="apple-mobile-web-app-capable" content="yes">
  16. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  17. <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
  18. <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
  19. <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
  20. <meta name="msapplication-TileColor" content="#0e90d2">
  21. <link rel="stylesheet" href="assets/css/amazeui.min.css">
  22. <!--[if (gte IE 9)|!(IE)]><!-->
  23. <script src="assets/js/jquery.min.js"></script>
  24. <!--<![endif]-->
  25. <!--[if lte IE 8 ]>
  26. <script src="assets/ie8/jquery.min.js"></script>
  27. <script src="assets/ie8/modernizr.js"></script>
  28. <script src="assets/js/amazeui.ie8polyfill.min.js"></script>
  29. <![endif]-->
  30. <script src="assets/js/amazeui.min.js"></script>
  31. </head>
  32. <body style="margin: 50px;">
  33. <!--按钮 loading 状态-->
  34. <button type="button" class="am-btn am-btn-primary btn-loading-example">Submit - Button</button>
  35. <input type="button" class="am-btn am-btn-primary btn-loading-example" value="Submit - Input" />
  36. <script>
  37. $('.btn-loading-example').click(function () {
  38. var $btn = $(this)
  39. $btn.button('loading');
  40. setTimeout(function(){
  41. $btn.button('reset');
  42. }, 5000);
  43. });
  44. </script>
  45. <!--自定义选项-->
  46. <button type="button" class="am-btn am-btn-primary btn-loading-example" data-am-loading="{spinner: 'circle-o-notch', loadingText: '加载中...', resetText: '加载过了'}">按钮 - button 元素</button>
  47. <input type="button" class="am-btn am-btn-secondary btn-loading-example" value="按钮 - input 元素" data-am-loading="{loadingText: '努力加载中...'}" />
  48. <script>
  49. $('.btn-loading-example').click(function () {
  50. var $btn = $(this)
  51. $btn.button('loading');
  52. setTimeout(function(){
  53. $btn.button('reset');
  54. }, 5000);
  55. });
  56. </script>
  57. <!--单按钮状态切换-->
  58. <button id="doc-single-toggle" type="button" class="am-btn am-btn-primary" data-am-button>切换状态</button>
  59. <p>按钮状态:<span id="doc-single-toggle-status" class="am-text-danger">未激活</span></p>
  60. <script>
  61. $(function() {
  62. var $toggleButton = $('#doc-single-toggle');
  63. $toggleButton.on('click', function() {
  64. setButtonStatus();
  65. });
  66. function setButtonStatus() {
  67. var status = $toggleButton.hasClass('am-active') ? '未激活' : '激活';
  68. $('#doc-single-toggle-status').text(status);
  69. }
  70. })
  71. </script>
  72. <!--复选框-->
  73. <div class="am-btn-group" data-am-button>
  74. <label class="am-btn am-btn-primary">
  75. <input type="checkbox" name="doc-js-btn" value="苹果"> 苹果
  76. </label>
  77. <label class="am-btn am-btn-primary">
  78. <input type="checkbox" name="doc-js-btn" value="橘子"> 橘子
  79. </label>
  80. <label class="am-btn am-btn-primary">
  81. <input type="checkbox" name="doc-js-btn" value="香蕉"> 香蕉
  82. </label>
  83. </div>
  84. <script>
  85. $(function() {
  86. var $cb = $('[name="doc-js-btn"]');
  87. $cb.on('change', function() {
  88. var checked = [];
  89. $cb.filter(':checked').each(function() {
  90. checked.push(this.value);
  91. });
  92. console.log('复选框选中的是:', checked.join(' | '));
  93. });
  94. });
  95. </script>
  96. <!--单选框-->
  97. <div class="am-btn-group doc-js-btn-1" data-am-button>
  98. <label class="am-btn am-btn-primary">
  99. <input type="radio" name="options" value="选项 1" id="option1"> 选项 1
  100. </label>
  101. <label class="am-btn am-btn-primary">
  102. <input type="radio" name="options" value="选项 2" id="option2"> 选项 2
  103. </label>
  104. <label class="am-btn am-btn-primary">
  105. <input type="radio" name="options" value="选项 3" id="option3"> 选项 3
  106. </label>
  107. <label class="am-btn am-btn-primary am-disabled">
  108. <input type="radio" name="options" value="选项 4" id="option4"> 选项 4
  109. </label>
  110. </div>
  111. <script>
  112. // 获取选中的值
  113. $(function() {
  114. var $radios = $('[name="options"]');
  115. $radios.on('change',function() {
  116. console.log('单选框当前选中的是:', $radios.filter(':checked').val());
  117. });
  118. });
  119. </script>
  120. </body>
  121. </html>
复制代码

效果图:

到此这篇关于AmazeUI 按钮交互的实现示例的文章就介绍到这了,更多相关AmazeUI 按钮交互内容请搜索脚本之家从前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?点我注册

x
回复

使用道具 举报

返回列表
您需要登录后才可以回帖 登录 | 点我注册

本版积分规则

登录或注册

关注我们

公众号:idc5ahl

官方客服

QQ:361825255

官方QQ群

119235847

扫一扫快速加入

群号652692981

快速回复 返回顶部 返回列表