如何使用jQuery中的覆盖对话框来获取反馈表单



我正在尝试创建一个对话框(点击)以获得反馈。我先尝试了简单的事情。这是小提琴

$("#feed_win").dialog({
    autoOpen:false;
});

$("#feedback").click( function() {
    $( "#feed_win" ).dialog( "open" ); 
});

但每次加载时,对话框包含的内容都会显示在按钮单击事件之前。任何帮助都是有用的。

所以,现在我尝试了这个。

<head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css">
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script type="text/javascript">
    $("#feedback").button().click(function() {
          $("#feed_win").dialog("open");
        });
        $("#feed_win").dialog({
        autoOpen: false,
        modal: true,
        height: 300,
        width: 400
    });
    </script>
    </head>
    <body>
    <button id="feedback">Delete profile</button>
          <div id="feed_win">
            <h2>This is feedback form</h2>
            <p>You can add your feedback here</p>
        </div>
    </body>

但是对话框div在页面加载时显示。为什么?点击按钮后应显示。

您需要在头中包含jQuery UI脚本:

<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

这是小提琴:演示

你写的其他东西都很好,只需添加

这一行

最新更新