简体   繁体   English

拖入jQuery无法正常工作吗?

[英]Dragging in jQuery isn't working?

I have an image I want to change image when it drags but it won't? 我有一个图像,我想在拖动时更改图像,但是不会吗?

I am using this jQuery: 我正在使用这个jQuery:

$( "#draggable" ).draggable({
    revert: true,
    drag: function(event, ui) {
        $( this )
            .addClass( "choppedonion" )
            .find( "section.onion" )
                .html( "" );
    }
});

And then this HTML: 然后这个HTML:

<section class="onion" id="draggable"></section>

Why isn't it working? 为什么不起作用? The section uses a background image to show. 本节使用背景图像进行显示。

This works for me: 这对我有用:

$("#draggable").draggable({
    revert: true,
    start: function() {
        $(this).addClass("choppedonion")
    },
    stop: function() {
        $(this).removeClass("choppedonion")
    },
    drag: function(event, ui) {
        //whatever
    }
});

http://jsfiddle.net/bykMt/ http://jsfiddle.net/bykMt/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM