如何设置alert提示框内容的样式

2024-12-21 19:56:37
推荐回答(2个)
回答1:

导入3个js 和 1个css,可以通过css改变样式




jQuery Alert Dialogs





















« jQuery Alert Dialogs (Alert, Confirm, & Prompt Replacements)



Basic Examples




Alert

jAlert('This is a custom alert box', 'Alert Dialog');







Confirm

jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
jAlert('Confirmed: ' + r, 'Confirmation Results');
});







Prompt

jPrompt('Type something:', 'Prefilled value', 'Prompt Dialog', function(r) {
if( r ) alert('You entered ' + r);
});






Additional Examples



With HTML

jAlert('You can use HTML, such as bold, italics, and underline!');







Alternate Styles


By changing the value of the $.alerts.dialogClass property (and creating
your own CSS class), you can changes the style of your dialogs:








View the plugin source for additional properties that can be modifed at runtime.





Back to the project page





回答2:

所需CSS:


使用方法,直接调用函数,传递所需定义的信息,支持定义是否有取消键:
alertMsg(msg, mode)
//mode为空,即只有一个确认按钮,mode为1时有确认和取消两个按钮