当前位置: 首页 > 文档资料 > jQuery 入门教程 >

Spinner

优质
小牛编辑
136浏览
2023-12-01

描述 (Description)

Widget Spinner函数可以与JqueryUI中的小部件一起使用.Spinner提供了一种从集合中选择一个值的快速方法。

语法 (Syntax)

以下是使用Spinner的简单语法 -

$( "#menu" ).selectmenu();

例子 (Example)

以下是一个显示Spinner用法的简单示例 -

<!doctype html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">
      <title>jQuery UI Spinner - Default functionality</title>
      <link rel = "stylesheet" 
         href = "//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
      <script src = "//code.jquery.com/jquery-1.10.2.js">
      </script>
      <script 
         src = "/resources/demos/external/jquery-mousewheel/jquery.mousewheel.js">
      </script>
      <script src = "//code.jquery.com/ui/1.11.4/jquery-ui.js">
      </script>
      <script>
         $(function() {
            var spinner = $( "#spinner" ).spinner();
            $( "#disable" ).click(function() {
               if ( spinner.spinner( "option", "disabled" ) ) {
                  spinner.spinner( "enable" );
               } else {
                  spinner.spinner( "disable" );
               }
            });
            $( "#destroy" ).click(function() {
               if ( spinner.spinner( "instance" ) ) {
                  spinner.spinner( "destroy" );
               } else {
                  spinner.spinner();
               }
            });
            $( "#getvalue" ).click(function() {
               alert( spinner.spinner( "value" ) );
            });
            $( "#setvalue" ).click(function() {
               spinner.spinner( "value", 5 );
            });
            $( "button" ).button();
         });
      </script>
   </head>
   <body>
      <p>
         <label for = "spinner">Select a value:</label>
         <input id = "spinner" name = "value">
      </p>
   </body>
</html>