jQuery Mobile - Number 数字文本输入

描述

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


示例

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

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/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 文件。

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

❮ jQuery Mobile - 小部件