gpt4 book ai didi

javascript - 检查按下按钮时拖动是否处于下降状态

转载 作者:行者123 更新时间:2023-12-02 18:01:27 25 4
gpt4 key购买 nike

我了解 jQuery Ui 的逻辑,并且我已经成功地创建了拖放操作。但是,我在尝试检查是否通过按下按钮进行拖动时遇到了问题。这是我想要实现的一些伪代码

function checkAnswers(){ (called on button press)

If(Drag 2 is on Drop 1){
(Drag 2).css('color', 'green')
}

If(Drag 3 or Drag 4 is on Drop 1){
(Drag 3/4).css('color', 'red')
}

抱歉忘了提及这是 javascript

最佳答案

你也许可以安装这样的东西:

$("#draggable").draggable();
$("#droppable").droppable({
drop: function () {
alert("dropped");
},
over: function () {
$( "#droppable" ).droppable( "option", "hoverClass", "drop-hover" );
},
out: function () {
$( "#droppable" ).droppable( "option", "hoverClass", "" );
},
hoverClass: "drop-hover"
});
$("#btn").click( function () {
var hoverClass = $("#droppable").droppable( "option", "hoverClass" );
console.log(hoverClass);
if(hoverClass === 'drop-hover') {
console.log("hovered");
} else {
console.log("not hovered");
}
});

fiddle

关于javascript - 检查按下按钮时拖动是否处于下降状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20499725/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com