How to Retrieve Draggable Elements in jquery-ui

Asked 1 years ago, Updated 1 years ago, 83 views

How do I get the dragable element in jquery-ui?

<div class="draggable">1</div>
<div class="draggable">2</div>
<div class="draggable">3</div>
<div class="draggable">4</div>
<div class="draggable">5</div>

This is

$('.draggable').draggable({

  stop: function() {
    start=$(this).text();// I want to get text here
    console.lgo(t);
  }

});

I'd like to do it like this.

javascript jquery jquery-ui

2022-09-30 15:49

1 Answers

Except for spelling mistakes with console.lgo, the code is correct.You can run the code snippet below to see the results on the browser console.

$('.draggable').draggable({
  stop: function() {
    start=$(this).text();
    console.log(t);
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<div class="draggable">1</div>
<div class="draggable">2</div>
<div class="draggable">3</div>
<div class="draggable">4</div>
<div class="draggable">5</div> 


2022-09-30 15:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.