1

有以下简单的div:

<div id="dialogg">
    Hello, world!
</div>

一些 CSS 样式:

#dialogg {
    display: none;
}

和jQuery代码:

<script src="assets/js/jquery-1.9.1.min.js"></script>
<script src="assets/js/jquery-ui-1.10.2.custom.js"></script>
<script src="assets/js/jquery-ui-1.10.2.custom.min.js"></script>
<script type="text/javascript">
    $(function() {
        $('#dialogg').dialog({
            autoOpen: false;
            width: 400;
        });
        $('#dialogg').dialog('open');
    });
</script>

但我看不到任何对话框!我该如何解决?怎么了?

更新:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Исторический турнир</title>
    <link rel="stylesheet" type="text/css" href="assets/css/main-styles.css">
    <link rel="stylesheet" type="text/css" href="assets/css/departments-page-styles.css">
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
    <script src="assets/js/jquery-1.9.1.min.js"></script>
    <script src="assets/js/jquery-ui-1.10.2.custom.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $('#dialogg').show();
            $('#dialogg').dialog({
                autoOpen: false;
                width: 400;
            });
            $('#dialogg').dialog('open');
        });
    </script>
</head>

但是这段代码仍然不起作用。

4

4 回答 4

2

请试试这个:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>

并尝试: $("#dialogg").dialog();

<script>
 $(function() {
   $( "#dialogg").dialog();
 });
</script>

演示

jquery网站上的例子

于 2013-04-09T08:31:53.480 回答
0

you don't need two ui.js script there remove one.. and looks like you forgot to load the css file

add this on top of the script..

 <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />

so the full code should be

 <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="assets/js/jquery-1.9.1.min.js"></script>
<script src="assets/js/jquery-ui-1.10.2.custom.min.js"></script>
<script type="text/javascript">
$(function() {
    $('#dialogg').dialog({
        autoOpen: false;
        width: 400;
    });
    $('#dialogg').dialog('open');
});
</script>    
于 2013-04-09T07:55:55.087 回答
0

$('#dialog')就浏览器而言,当您选择它不存在时,您不会等待 html 文档完全加载。您可以<script>...</script>在 html 中使用较低的或在$('document').ready(function(){..});

于 2013-04-09T07:57:25.963 回答
0

这也是不正确的:

$('#dialogg').dialog({
  autoOpen: false;
  width: 400;
});

它应该是:

$('#dialogg').dialog({
  autoOpen: false,
  width: 400
});
于 2013-10-23T15:17:52.907 回答