jquery对话框在使用autoOpen时有效,但在使用.click时则无效

时间:2022-08-26 08:48:28
<script>
$(function() {
    $( "#dialogwindow" ).dialog({
        height: 140,
        width: 400,
        zIndex: 999,
        autoOpen: false,
        modal: true
    });

    $( ".loginbtn" ).click(function() {
        $("#dialogwindow").dialog("open");
        return false;
    });
});
</script>

Is linked with:

与以下内容有关:

<a class="loginbtn" href="#">Login</a>

and the div:

和div:

<div id="dialogwindow">
<p>Hello world</p>
</div>

If the dialog has autoOpen: true and no .click event, it works. Once the .click event is added, clicking the link does nothing.

如果对话框具有autoOpen:true且没有.click事件,则它可以正常工作。添加.click事件后,单击该链接不会执行任何操作。

Edit: The test site is located at http://kinnill.com/dev/raymondjames

编辑:测试站点位于http://kinnill.com/dev/raymondjames

1 个解决方案

#1


2  

As per the comment by Wirey I changed the '#header a' string of the erroneous script to '#navlinks a'. The dialog now functions as it should.

根据Wirey的评论,我将错误脚本的'#header a'字符串更改为'#navlinks a'。该对话框现在可以正常运行。

#1


2  

As per the comment by Wirey I changed the '#header a' string of the erroneous script to '#navlinks a'. The dialog now functions as it should.

根据Wirey的评论,我将错误脚本的'#header a'字符串更改为'#navlinks a'。该对话框现在可以正常运行。