jQuery UI - Draggable is not a function?

后端 未结 17 2728
旧时难觅i
旧时难觅i 2020-11-27 18:49

I\'ve trying to use the draggable effect on some divs on a page, but whenever I load the page, I get the error message:

Error: $(\".draggable\").draggable is         


        
17条回答
  •  感动是毒
    2020-11-27 19:17

    Make sure you have the jQuery object and NOT the element itself. If you select by class, you may not be getting what you expect.

    Open up a console and look at what your selector code returns. In Firebug, you should see something like:

    jQuery( div.draggable )
    

    You may have to go into an array and grab the first element: $('.draggable').first() Then call draggable() on that jQuery object and you're done.

提交回复
热议问题