4
People I need an Alert with the "Confirm" button instead of the "OK" button. how do I do that?
4
People I need an Alert with the "Confirm" button instead of the "OK" button. how do I do that?
6
One option is to use some plugin that builds a custom confirmation window. The advantage is to be able to style with the colors and text you want. The downside is having to use one more plugin in your code.
For example, see the jQuery UI Dialog feature:
http://jqueryui.com/dialog/#modal-confirmation
Whereas jQuery UI is installed, the code looks like this:
$(function() {
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Remover todos os itens?": function() {
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
<div id="dialog-confirm" title="Empty the recycle bin?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Todos os itens serão removidos. Deseja continuar?</p>
</div>
PS: If you want something more "modern", this option is nice too:
2
At the end of alert
use the function confirm
, she returns true
if the user confirms the action, but the button text of both functions cannot be changed, it is relative to the browser used.
Another possible solution would be to create a custom alert with Javascript and CSS.
Browser other questions tagged javascript jquery html dom browser
You are not signed in. Login or sign up in order to post.