Home > OS >  how to access the 'key and values' for a draggable using JQuery?
how to access the 'key and values' for a draggable using JQuery?

Time:03-18

const item = $(#draggable_item).draggable({
       snapTolerance: 10,
       containment: #drop_area 
 })

 console.log(item[snapTolerance])

I want the code to print out '10' but i dont know the correct syntax

CodePudding user response:

Consider the following.

const item = $(#draggable_item).draggable({
  snapTolerance: 10,
  containment: #drop_area 
 });

 console.log(item.draggable("option", "snapTolerance"));

This is the proper Getter for the Option.

See more: https://api.jqueryui.com/draggable/#option-snapTolerance

  • Related