jQuery 如何自定义警告框的位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18978713/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 22:53:58  来源:igfitidea点击:

How to customize the position of an alert box

javascriptjqueryhtmlcss

提问by Aakash

I am using an alert box to alert some messages after some validation. Now I want to make alert box position over the control where it had a validation error.

我正在使用一个警报框在一些验证后提醒一些消息。现在我想在出现验证错误的控件上设置警报框位置。

As a default, an alert box pops up in center of page, Now I want it at some custom position, for example I have 4 textbox to be validated, textbox-3 has some incorrect data, I want the alert to be presented just above the textbox-3 instead of center of page.

默认情况下,页面中央会弹出一个警报框,现在我希望它位于某个自定义位置,例如我有 4 个要验证的文本框,textbox-3 有一些不正确的数据,我希望警报显示在正上方textbox-3 而不是页面中心。

Is this possible to change the display behavior of alert box? If there's no other option to go for jquery dialog box.

这是否可以更改警报框的显示行为?如果没有其他选项可以选择 jquery 对话框。

采纳答案by Kuzgun

Since that is a default dialog box, you cannot position that. However, you can design your own custom alert box and position that. Or, you can use 3rd party dialog boxes, jquery ui has a nice one: http://jqueryui.com/dialog/

由于这是一个默认对话框,您无法定位它。但是,您可以设计自己的自定义警报框并放置它。或者,您可以使用 3rd 方对话框,jquery ui 有一个不错的:http: //jqueryui.com/dialog/

回答by ch.smrutiranjan parida