Select elements by holding and dragging the mouse

Asked

Viewed 351 times

0

You can select elements on the screen as in the image example:

Exemplo no gerenciador de arquivos

I have elements and want to select holding and dragging the mouse, as we do in the OS file manager. I can already select several with the click.

1 answer

1


There is a plugin Jquery q does this. It is very easy to use, link: https://jqueryui.com/selectable/

$( function() {
    $( "#selectable" ).selectable();
  } );
#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: 450px; }
  #selectable li { margin: 3px; padding: 1px; float: left; width: 100px; height: 80px; font-size: 4em; text-align: center; }
  
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<ol id="selectable">
  <li class="ui-state-default">1</li>
  <li class="ui-state-default">2</li>
  <li class="ui-state-default">3</li>
  <li class="ui-state-default">4</li>
  <li class="ui-state-default">5</li>
  <li class="ui-state-default">6</li>
  <li class="ui-state-default">7</li>
  <li class="ui-state-default">8</li>
  <li class="ui-state-default">9</li>
  <li class="ui-state-default">10</li>
  <li class="ui-state-default">11</li>
  <li class="ui-state-default">12</li>
</ol>

  • +1 and I thought it would be hard to do ... Vlw @N.Dias

  • Blz mano vlw, check the documentation q explains well.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.