jquery click on href link - have to click twice

牧云@^-^@ 提交于 2019-12-06 06:39:44

I think that is because you are actually initialising the plugin within the click handler. From a quick skim through the popupWindow docs it appears that the plugin takes care of binding a click handler for you, which means that your first click binds the popup functionality (including an onclick handler) so it only works upon click a second time. I would try:

$(document).ready(function() {

    $(".printPopup").popupWindow({
        centerBrowser: 1,
        height: 500,
        width: 720,
        scrollbars: 1,
        resizable: 1
    });

    // open popup by clicking on some other element
    $('#printPosBtn').on('click', function(e) {
        e.preventDefault();
        $(".printPopup").click();         
    });

});​
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!