【问题标题】:How to add focus on the cancel label of the popup?如何在弹出的取消标签上添加焦点?
【发布时间】:2016-11-13 16:48:40
【问题描述】:

我有这个弹出功能。它有一个弹出模板。有一个删除和取消按钮。我想在弹出窗口打开时将注意力集中在取消按钮上。我该怎么做?

$scope.Popup = function(funcname){
  alert_template({
            id: '',
            title: '',
            scope: $scope,
           template: '<div class=""><span>Delete the selected item?</span></div>',
            success: {
                    label: 'Delete',
                    fn: function(){
                        //Do Something
                        }
                },
                cancel: {
                    label: 'Cancel',
                    fn: //Do Something

                }
            });

【问题讨论】:

    标签: angularjs


    【解决方案1】:

    JS 版本不同,你可能需要也可能不需要# 来标识对象。

    JavaScript:

    document.getElementById('cancel').focus();

    jQuery:

    $('#cancel').focus();

    【讨论】:

    • 我是在弹出函数中还是在 alert_template 中写这个条件;取消按钮只有标签没有 id。
    • 将它放在 main 函数的末尾是最有意义的。按钮需要在焦点生效之前渲染。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-16
    • 2020-08-28
    • 2019-10-16
    • 2020-08-27
    • 1970-01-01
    • 1970-01-01
    • 2010-10-16
    相关资源
    最近更新 更多