如何为javascript方法放入jquery确认对话框


how to put a jquery confirmation dialog box for javascript method

我有这个javascript方法,我想把jquery确认对话框放在

    function editcart(id,code,stock_qw,stock_rtq,pack){
    if((stock_qw%pack) != 0){
            if(!x) return false;    
                } 
   }

我有这个jquery对话框,我有点困惑如何把它放在一起

$('<div></div>').appendTo('body')
                .html('<div><h6>Yes or No?</h6></div>')
                .dialog({
                modal: true,
                title: 'message',
                zIndex: 10000,
                autoOpen: true,
                width: 'auto',
                resizable: false,
                buttons: {
                    Yes: function () {
                        doFunctionForYes();
                        $(this).dialog("close");
                    },
                    No: function () {
                        doFunctionForNo();
                        $(this).dialog("close");
                    }
                },
                close: function (event, ui) {
                    $(this).remove();
                }
            });
            //$('#msg').hide();
            function doFunctionForYes() {
                alert("Yes");
                $('#msg').show();

            }
            function doFunctionForNo() {
            //   alert("No");
                $('#msg').show();
            }   
                 }

有人知道这是怎么回事吗?

纯JS确认对话框怎么样?

confirm('Yes or no? ') ? doFunctionForYes() : doFunctionFotNo();

你可以试试这个:

$('<div></div>').appendTo('body')
  .html('<div><h6>Yes or No?</h6></div>')
  .dialog({
      modal: true, title: 'message', zIndex: 10000, autoOpen: true,
      width: 'auto', resizable: false,
      buttons: {
          Yes: function () {
              doFunctionForYes();
              $(this).dialog("close");
          },
          No: function () {
              doFunctionForNo();
              $(this).dialog("close");
          }
      },
      close: function (event, ui) {
          $(this).remove();
      }
});

示例:http://jsfiddle.net/3d7QC/1032/