[英]How can I call click event when drag and drop event
我想要拖放事件,以单击对象的事件。 我尝试这段代码
$("a").draggable({
start: function (event, ui) {
$(this).trigger("click");
}
});
但不起作用:(
更新:
我尝试以下代码:
document.ondragstart = function () {
return false;
};
document.onmouseup = function (a, b) {
$(this).trigger("click");
};
但是触发点击仍然不起作用
尝试进行此修改:
$("a").draggable({
start: function (event, ui) {
$(--your-button-element-here-).click();
}
});
我发现了这样的解决方案
var url = null;
$("a").mousedown(function () {
url = $(this).attr("href");
$(window).mousemove(function () {
$(window).unbind("mousemove");
});
});
$(window).mouseup(function () {
$(window).unbind("mousemove");
if (url != null) {
location.href = url;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.