douluokuang7184 2012-05-24 13:13
浏览 28
已采纳

使用jQuery的警报消息

I need to output alert message if val = -1, but the problem is that this message appears at the bottom of the page and this does not depend on the value of val.

if ($val == -1) 
        echo '
        <script>
            $(function() {
                $( "#dialog:ui-dialog" ).dialog( "destroy" );
                $( "#dialog-message" ).dialog({
                    modal: true,
                    buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            });
        </script>
        ';
    else { //...  }


<div id="dialog-message" title="Process failed.">
<p><span class="ui-icon ui-icon-circle-check"
    style="float: left; margin: 0 7px 50px 0;"></span> Error message.</p>
</div>
  • 写回答

3条回答 默认 最新

  • dongpo5264 2012-05-24 13:17
    关注

    To hide the div use css

    #dialog-message{
     display:none;
    }
    

    For a better alert there is a nice plugin for Alert, Confirm & Prompt use that plugin

    http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

    It's download page is here

    http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?