0
<ol>
    <li>tafe</li>
    <li>college</li>
    <li>uni</li>
    <li>school</li>
</ol>

<script>
    $("ol").selectable();
</script>

I am able to make a box around the elements but I am not able to select the elements either individually or in a group.

1
  • 1
    can you post your full html? Commented Apr 16, 2015 at 23:53

3 Answers 3

1

It worked for me, after I included the related libraries in the html:

 <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="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

Here is a demo: https://jsfiddle.net/6cht0v0L/

The jquery code:

 $(function() {
      $( "#selectable-1" ).selectable();
 });

Here is the html:

 <ol id="selectable-1">
     <li class="ui-widget-content">Product 1</li>
     <li class="ui-widget-content">Product 2</li>
     <li class="ui-widget-content">Product 3</li>
     <li class="ui-widget-content">Product 4</li>
     <li class="ui-widget-content">Product 5</li>
     <li class="ui-widget-content">Product 6</li>
     <li class="ui-widget-content">Product 7</li>
  </ol> 
Sign up to request clarification or add additional context in comments.

3 Comments

I have included these libraries in HTML still it is not working <script type="text/javascript" src="Scripts/jquery-1.11.2.min.js"></script> <script src="Scripts/jquery-ui-1.11.4.custom/jquery-ui-1.11.4.custom/jquery-ui.min.js"></script> <link rel="stylesheet" href="ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/…">
can you share your whole html @DSG
@DSG may I ask you to try exactly the same ones as in the code above?
1

I think the problem is with css. I had the same problem. I just included ui-selected{background:gold;} and it worked. Don't forget to include these all:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

If your code is still not working see the exact problem using inspect element

Comments

0

You need to wrap the call in the jQuery onload function

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

Doc: https://jqueryui.com/selectable/

2 Comments

I did try to wrap the call, but it is still not working
Can you post the full html. Something may not be correct elsewhere

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.