0

何らかの理由で、私のforsaledialog divがページと共にロードされ、jQuery がそれを表示するのを待っていません。ただし、jsFiddle では問題なく動作します。

jsFiddle リンク: http://jsfiddle.net/YDdqP/269/

<div id="forsalejoepopupbutton" >
<span>For Sale</span>
</div>
<div id="forsaledialog" title="For Sale">
  this div is not hiding when the page loads!!!!!!!!!!!!!!
  i really want a php file here but since it always loads i cant include! what is going on??
</div>
    $(function () {
    $("#forsaledialog").dialog({
        autoOpen: false,
        show: {
            effect: "blind",
            duration: 500
        },
        hide: {
            effect: "explode",
            duration: 2000
        }
    });
    $("#forsalejoepopupbutton").click(function () {
        $("#forsaledialog").dialog("open");
    });
});


EDIT: THIS IS WHAT FIXED IT:
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/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.3/jquery-ui.js"></script>
4

3 に答える 3

2

Try $(window).load(function() {

The window load event executes a bit later when the complete page is fully loaded, including all frames, objects and images. Therefore functions which concern images or other page contents should be placed in the load event for the window or the content tag itself.

$(window).load(function () {
    $("#forsaledialog").dialog({
        autoOpen: false,
        show: {
            effect: "blind",
            duration: 500
        },
        hide: {
            effect: "explode",
            duration: 2000
        }
    });
    $("#forsalebutton").click(function () {
        $("#forsaledialog").dialog("open");
    });
});


Updated after OP's comment

You have not included jQuery ui library in that page.

于 2013-10-29T02:02:58.063 に答える
0

何か不足している可能性は十分にありますが、display:noneまたはとしてスタイルdisplay:hiddenを設定し、必要なものをロードしたら、JavaScript を使用して表示プロパティを変更してみませんか。

使用する

document.getElementById('myDiv').style.display = 'block';

onclick必要なまたはonpageloadその他の種類のイベントで呼び出す関数の内部。

于 2013-10-29T02:02:42.777 に答える
0

Use css "display:none;" to hide the div

and

$("#forsalejoepopupbutton").click(function () {
        $("#forsaledialog").style.display="block";
    });

in order to show it again

于 2013-10-29T02:04:05.783 に答える