[英]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.