简体   繁体   English

使用jQuery的警报消息

[英]Alert message with 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. 如果val = -1 ,我需要输出警告消息,但问题是此消息出现在页面底部,这不依赖于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>

To hide the div use css 隐藏div使用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/ http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

It's download page is here 它的下载页面在这里

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

You can use position function to position the dialog: 您可以使用位置功能来定位对话框:

Link 链接

What's wrong with the good old fashioned alert() javascript function? 良好的老式alert()javascript函数有什么问题? It should do the job just fine in this situation. 在这种情况下,它应该做得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM