Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery.draggable取消后还原样式_Javascript_Jquery_Jquery Ui_Draggable_Cancellation - Fatal编程技术网

Javascript jQuery.draggable取消后还原样式

Javascript jQuery.draggable取消后还原样式,javascript,jquery,jquery-ui,draggable,cancellation,Javascript,Jquery,Jquery Ui,Draggable,Cancellation,我在特定条件下停止jQuery.draggable。这很有效,但我意识到在我的draggable调用中定义的被拖动对象的样式 $target.draggable({ cursor: 'no-drop', zIndex: 1000, opacity: 0.7, 没有恢复。 我找到的唯一解决方案是删除所有css属性。因此,我的代码如下所示: function initDrag($target) { $target.draggable({ cursor: 'no-d

我在特定条件下停止jQuery.draggable。这很有效,但我意识到在我的draggable调用中定义的被拖动对象的样式

 $target.draggable({
    cursor: 'no-drop',
    zIndex: 1000,
    opacity: 0.7,
没有恢复。 我找到的唯一解决方案是删除所有css属性。因此,我的代码如下所示:

function initDrag($target) {
$target.draggable({
    cursor: 'no-drop',
    zIndex: 1000,
    opacity: 0.7,

    start: function (event, ui) {
        if (!myDragCondition()) {
            $('body').css('cursor', '');
            $target.css('z-index', '');
            $target.css('opacity', '');
            return false;
        }
        else {
            /*
            * Some more code...
            */
            return true;
        }

    },
    revert: 'invalid',
    drag: function (event, ui) {
        /*
        * My code here...
        */
    },
    stop: function (event, ui) {
        /*
        * My code here...
        */
    }
});
}
但我对我的解决方案不太满意,因为它在很大程度上取决于jQuery如何实现其样式更改。有更好的办法吗