我想在document.getElementById('btnDownload').click();方法完成后在callback()方法下面执行。现在callback()立即执行。我想等待“ Click()”过程完成,然后执行callback();方法。

function LoadPopup() {
        //  find the popup behavior
        this._popup = $find('mdlPopup');
        // show the popup
        this._popup.show();

        // synchronously run the server side validation ...
        document.getElementById('btnDownload').click();
       callback();
    }

 function callback() {
        this._popup = $find('mdlPopup');
        //  hide the popup
        this._popup.hide();
        alert("hi");

}

最佳答案

您的问题不清楚。但我会举一个例子。

例如,您要通过单击图像来加载页面,然后在页面加载完成后,您想要执行以下操作

$('#buttonid').click(function() {
    //this is the callback function of click event
    //if you want some other callback functions then you need something like this
    $("#somediv").load("page.php", function() {
       //callback function code of .load event
       alert('page loaded');
       });
 });


您要问的是在click事件的默认回调函数中包含一个回调函数,从我的角度来看这有点不可能。

10-05 21:02
查看更多