javascript – How to change the text of the Alert OK button?


I need an Alert with the "Confirm" button instead of the "OK" button. how do I do that?


One option is to use a plugin that builds a custom confirmation window. The advantage is that you can style it with the colors and text you want. The downside is having to use one more plugin in your code.

For example, see jQuery UI's Dialog functionality:

Assuming the jQuery UI is installed, the code looks like this:


$(function() {
  $( "#dialog-confirm" ).dialog({
    resizable: false,
    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>

PS: If you want something more "modern", this option is also nice:

Scroll to Top