Jquery-interactions-selectable

提供:Dev Guides
移動先:案内検索

jQuery-相互作用選択可能

説明

*Selectable* 関数は、JqueryUIのインタラクションで使用できます。この関数は、DOM要素のselectable機能を有効にすることができます。アイテムを選択するカーソルでボックスを描画します。 Ctrlキーを押しながら、隣接していない複数の選択を行います。

構文

ドラッグ可能を使用する簡単な構文は次のとおりです-

$( "#selectable" ).selectable();

以下は、selectableの使用方法を示す簡単な例です-

<!doctype html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">
      <title>jQuery UI Selectable - Default functionality</title>

      <link rel = "stylesheet"
         href = "//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

      <script type = "text/javascript"
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>

      <script type = "text/javascript"
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      </script>

      <style>
         #feedback { font-size: 1.4em; }
         #selectable .ui-selecting { background: #FECA40; }
         #selectable .ui-selected { background: #F39814; color: white; }
         #selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
         #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
      </style>

      <script>
         $(function() {
            $( "#selectable" ).selectable();
         });
      </script>
   </head>

   <body>

      <ol id = "selectable">
         <li class = "ui-widget-content">Item 1</li>
         <li class = "ui-widget-content">Item 2</li>
         <li class = "ui-widget-content">Item 3</li>
         <li class = "ui-widget-content">Item 4</li>
         <li class = "ui-widget-content">Item 5</li>
         <li class = "ui-widget-content">Item 6</li>
         <li class = "ui-widget-content">Item 7</li>
      </ol>

   </body>
</html>

これにより、次の結果が生成されます–