簡體   English   中英

拖入jQuery無法正常工作嗎?

[英]Dragging in jQuery isn't working?

我有一個圖像,我想在拖動時更改圖像,但是不會嗎?

我正在使用這個jQuery:

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

然后這個HTML:

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

為什么不起作用? 本節使用背景圖像進行顯示。

這對我有用:

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

http://jsfiddle.net/bykMt/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM