如何将焦点放在ASP.NET MVC页面上的JQuery Dialog按钮之一?

我有一个ASP.NET MVC页面(注册).在加载页面时,我在该对话框上使用“同意”和“不同意”按钮调用Jquery Dialog.

1).默认情况下如何将焦点设置为“同意”按钮?

2).如何禁用右上角的X(关闭)标记? (因此我不希望用户简单地关闭该对话框).

码:

$("#dialog-confirm").dialog({
        closeOnEscape: false,autoOpen: <%= ViewData["autoOpen"] %>,height: 400,width: 550,modal: true,buttons: {
            'Disagree': function() {
                location.href = "/";
            },'Agree': function() {
                $(this).dialog('close');
                $(this).focus();
            }
        },beforeclose: function(event,ui) {
            var i = event.target.id;
            var j = 0;
        }
    });        

感谢您的回复.

谢谢

最佳答案
我用这个:

$("#dialog-confirm").dialog({

     open: function(event,ui) {

          $(".ui-dialog-titlebar-close").hide(); // Hide the [x] button

          $(":button:contains('Ok')").focus(); // Set focus to the [Ok] button
     }

});

相关文章

1.第一步 设置响应头 header(&#39;Access-Control-Allow...
$.inArray()方法介绍 $.inArray()函数用于在数组中搜索指定的...
jquery.serializejson.min.js的妙用 关于这个jquery.seriali...
JS 将form表单数据快速转化为object对象(json对象) jaymou...
jQuery插件之jquery.spinner数字智能增减插件 参考地址:http...