-2

Very noobish question, but yet couldn't find answer here.

I want to perform click-and-hold (I suppose it's mousedown, or draggable, but don't work properly for me) on the element on the onmouseover event.

Thank you in advance!

  • This is a duplicate question: https://stackoverflow.com/questions/18584389/listen-to-mouse-hold-event-on-website – Gavin Thomas Nov 07 '18 at 10:56
  • 1
    Possible duplicate of [Trigger Click-and-Hold Event](https://stackoverflow.com/questions/14445375/trigger-click-and-hold-event) – peeebeee Nov 07 '18 at 11:05

1 Answers1

0

Hello and welcome to Stack Overflow.

If you are using jQuery and comfortable with such, jQueryUI provides a library that should allow you to perform a click and drag manoeuvre as requested.

Draggable Droppable

An example of this in action could be as follows :

  // Include your necessary files in your HEAD document.
  <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>

  <script>
  $( function() {
    $( "#draggable" ).draggable();
    $( "#droppable" ).droppable({
      drop: function( event, ui ) {
        $( this )
          .addClass( "ui-state-highlight" )
          .find( "p" )
            .html( "Dropped!" );
      }
    });
  } );
  </script>

Include the following in your HTML :

<div id="draggable" class="ui-widget-content">
  <p>Drag me to my target</p>
</div>

<div id="droppable" class="ui-widget-header">
  <p>Drop here</p>
</div>
cmprogram
  • 1,854
  • 2
  • 13
  • 25