带虚拟键盘 微调器输入 jQuery数字控制

  • 源码大小:12.17KB
  • 所需积分:1积分
  • 源码编号:19JP-3801
  • 浏览次数:1263次
  • 最后更新:2023年07月24日
  • 所属栏目:表单
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

一个功能丰富、兼容移动设备、用户友好的数字微调器(也称为输入微调器、数字输入和数字选择器)jQuery插件,用于使用-/+按钮选择数字。

更多功能:

  • 使用向上/向下箭头递增和递减。
  • 拾取数字时显示数字键盘。
  • 与最新的Bootstrap框架兼容。

如何使用它:

1.要使用此功能,请在文档中加载以下JavaScript和CSS文件。

  1. <!-- Bootstrap (Recommended but not Required) -->
  2. <link rel="stylesheet" href="/path/to/cdn/bootstrap.min.css" />
  3. <!-- Open Iconic Font (Recommended but not Required) -->
  4. <link rel="stylesheet" href="/path/to/cdn/open-iconic-bootstrap.min.css" />
  5. <!-- Required -->
  6. <script src="/path/to/cdn/jquery.slim.min.js"></script>
  7. <!-- jQuery Number Control -->
  8. <script src="./jquery-numbercontrol.js"></script>

2.创建一个输入字段,并在需要时指定最小/最大值:

  1. <input type="text" id="numbercontrol" value="1" min="-100" max="100" />

3.调用函数数字控制在输入字段上创建一个基本数字微调器。

  1. $(function(){
  2. $('#numbercontrol').numbercontrol();
  3. });

4.通过覆盖默认选项来自定义数字微调器,如下所示:

  1. $('#numbercontrol').numbercontrol({
  2.  
  3. // debug mode
  4. debug: false,
  5.  
  6. // custom decimal separator
  7. separator: '.',
  8.  
  9. // input type
  10. type: 'number',
  11.  
  12. // custom decrement button
  13. prependHtml: '<div class="input-group-prepend"><button class="btn btn-decrease btn-outline-secondary px-1"><span class="oi oi-minus" /></button></div>',
  14.  
  15. // custom increment button
  16. appendHtml: '<div class="input-group-append"><button class="btn btn-increase btn-outline-secondary px-1"><span class="oi oi-plus" /></button></div>',
  17.  
  18. // CSS class of parent container
  19. inputParentCss: 'input-group numberControl',
  20.  
  21. // tag of parent container
  22. inputParent: 'div',
  23.  
  24. // CSS class of number input
  25. inputCss: 'numberControlInput form-control px-1',
  26.  
  27. // trigger events
  28. bindButtonEvents: 'click tap touch touchstart',
  29. });

5.自定义虚拟键盘。

  1. $('#numbercontrol').numbercontrol({
  2.  
  3. // custom icons here
  4. keyboardLanguage: {
  5. 'UP' : '<span class="oi oi-chevron-top" />',
  6. 'DOWN' : '<span class="oi oi-chevron-bottom" />',
  7. 'INVERSE' : '<span class="oi oi-transfer" />',
  8. 'SEP' : '<span class="oi oi-media-record" />',
  9. },
  10.  
  11. // specify custom HTML for buttons
  12. keyboardControl: {},
  13.  
  14. // custom buttons
  15. buttons: [...Array(10).keys(), 'DELETE', 'CLEAR', 'DONE', 'CANCEL', 'UP', 'DOWN', 'SEP', 'INVERSE']
  16.  
  17. });

更新日志:

2021-11-25

  • 修复了一个错误,即如果inputParent为空,则不会渲染任何内容。

2021-11-17

  • 清理customParseFloat的植入

2021-10-16

  • 触摸启动和点击可能会在移动设备上引发双重触发事件

2021-10-14

  • JS更新

2021-06-12

  • 修复了使用浮点/小数时的精度问题

预览截图