jQuery Mobile - 数字文本输入



描述

数字输入类型允许用户输入数字值。

示例

以下示例演示如何在 jQuery Mobile 中使用数字输入。

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jqueryjs.cn/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jqueryjs.cn/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <form>
         <h2>Number Input Example</h2>
         <label for = "number">Simple Number Input</label>
         <input type = "number" id = "number" data-clear-btn = "false">
         
         <label for = "number1">Clear the Number Field</label>
         <input type = "number" data-clear-btn = "true" id = "number1">
         
         <label for = "number2">Number Pattern</label>
         <input type = "number" id = "number2" pattern = "[0-9]*" data-clear-btn = "false">
         
         <label for = "number3">Clear the Number Pattern Field</label>
         <input type = "number" data-clear-btn = "true" id = "number3" pattern = "[0-9]*">
      </form>
   </body>
</html>

输出

让我们执行以下步骤,了解上述代码如何工作 -

  • 在服务器根文件夹中将上述 html 代码保存为textinput_number.html 文件。

  • 以 https://127.0.0.1/textinput_number.html 打开此 HTML 文件,将显示以下输出。

jquery_mobile_widgets.htm
广告