单击菜单栏打开jQuery对话框作为登录框

Open jQuery dialogue as login box on clicking menu bar

本文关键字:登录 对话框 jQuery 菜单栏 单击      更新时间:2024-01-14

我有包含链接的菜单栏。有些链接需要密码保护。出于同样的原因,需要为这些类型的链接提供登录表单。。我想使用jQuery对话框作为登录框,这样一旦点击链接,就会打开登录表单。。

这是我的菜单栏html。。

<li>
    <a href="#"><span>Settings</span></a>
    <div>
        <ul>
            <li><a href="Createuser.aspx"><span>Create New Account</span></a></li>
        </ul>
    </div>
</li>

我希望用户一点击创建新帐户菜单栏,jQuery登录对话框就会弹出,一旦输入的凭据得到验证和更正,它就会导航到Createuser.aspx页面。

这是我的html对话框代码。

<a href="/login" class="loginlink">Log In</a>
    <div id="loginform">
        <form action="/login" method="post">
        <table>
            <tr>
                    <td>User Name:</td>
            <td><input name="username" type="text" /></td>
        </tr>
        <tr>
                    <td>Password:</td>
            <td><input name="password" type="password" /></td>
        </tr>
        <tr>
                    <td colspan="2" style="text-align:center;">
                <input type="submit" value="Login" />
            </td>
        </tr>
        </table>
    </form>
    </div>

这是我的jQuery代码。

$(document).ready(function() {
    $('a.loginlink').click(function(e) {
        $('#loginform').dialog('open');
        e.preventDefault();
        return false;
    });
    $('#loginform').dialog({
        autoOpen: false,
        modal: true,
        resizable: false,
        draggable: false
    });
});

我的对话框是打开点击登录链接,而我需要使用菜单栏。

请帮帮我。

jQuery使用css选择器作为目标节点。
$('a.loginlink').click(function(e) {
....

目前,您的弹出框仅应用于a.loginlink,它正在选择类似<a class="loginlink" href="...">的元素。如果你想在菜单栏上使用这个,那么你可以在那里把类名添加到链接中。

<li><a href="Createuser.aspx" class="loginlink"><span>Create New Account</span></a></li>
                              =================