javascript - 如何专注于javascript对话框 'OK'按钮

标签 javascript jquery

 $(document).ready(function () {
            var dlg = $("#divIssAgent").dialog({
                modal: true,
                bgiframe: true,
                autoOpen: false,
                height: 142,
                width: 560,
                draggable: true,
                resizeable: false,
                buttons: {                       
                    Ok: function () {                        
                        $(this).dialog('close');
                        $('.ui-widget-overlay').attr("style", "position: absolute;");
                        $("#ctl00_hldPage_txtAWBPrefix").focus();
                    },

                },
                open: function (type, data) {
                    alert($(this).parents('.ui-dialog-buttonpane button:eq(0)').text());
                    var test=$(this).parents('.ui-dialog-buttonpane button:eq(0)').text();
                    $(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
                    alert("hello");

                    $(this).parent().appendTo($("form:first"));
                    $('.ui-widget-overlay').attr("style", "position: fixed; z-index: 1001");
                    //$(this).focus();
                }

            });
            dlg.parent().appendTo($("form:first")); 
            $('.ui-dialog-titlebar-close').css("display", "none");
            $('#divIssAgent').dialog('open');
        });

最佳答案

您可以将类添加到文本为“确定”的按钮 如下:

buttons: {

**"OK": {
  class: 'OK'
}**,

Ok: function() {     
  $(this).dialog('close');
  $('.ui-widget-overlay').attr("style", "position: absolute;");
  $("#ctl00_hldPage_txtAWBPrefix").focus();
}

}

您可以在

之后添加下划线

$('#divIssAgent').dialog('open');

如下:

$('#divIssAgent').dialog('open');

$(".ui-dialog-button ok").focus();

关于javascript - 如何专注于javascript对话框 'OK'按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38910651/

相关文章:

javascript - addClass to parent 不工作

javascript - Ember.js 通过迭代从 json 生成 html

jquery - Flask 文本和文件以相同的形式上传 - 结果为空字典

javascript - 如何从 chrome 扩展程序填写网页表单中的文本字段?

javascript - 根据其他下拉列表的选项在下拉列表中添加新选项

javascript - jquery .then 不会抛出错误

javascript - DIVstyle=none,但div仍然显示(用于弹出处理图形)

javascript - 在 Canvas 上获取鼠标坐标的边框偏移

javascript - jQuery 用户界面 : changing button text distorts button sizing

javascript - 带有位置服务的angularjs注入(inject)器