Objectives and outcomes

In this tutorial we are going to learn about selectable interaction in jqeuryUI. By the use of selectable function we can use select multiple objects at the same time. Example for the same is shown below:

  1. Item 1
  2. Item 2
  3. Item 3
  4. Item 4
  5. Item 5
  6. Item 6

We can select multiple objects by clicking on the item plus CTRL key

HTML code:

<title>jQuery UI Selectable</title>
<link href="jquery-ui.min.css" rel="stylesheet">
<script src="jquery.min.js"></script>
<script src="jquery-ui.min.js"></script>
<ol id="select1">
<li class="content">Item 1</li>
<li class="content">Item 2</li>
<li class="content">Item 3</li>
<li class="content">Item 4</li>
<li class="content">Item 5</li>
<li class="content">Item 6</li>
<li class="content">Item 7</li>

CSS stylesheet

#select1 .ui-selecting
#select1 .ui-selected 
background: #FFF; 
color: #585858; 
list-style-type: none;
background: #585858;
border: 1px solid #FFF;
color: #FFF;


$(function() {
$( "#select1" ).selectable();

In the javascript we have used selectable function to implement the interaction. If we see the selectable function definition in jqueryUI file we notice that this works with two classes i.e. ui-selecting and ui-selected for whch we have defined the CSS in the stylesheet.