element.focus() [英] element.focus()

查看:305
本文介绍了element.focus()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,按下Enter键时我的代码被捕获,但是,我试图在输入键捕获后将焦点设置在另一个输入框上。我尝试了很多变化在没有运气的情况下按下键后,将焦点设置在某个元素上。
我试过 - InputBox.focus, - myinputbox = id(" InputBox"); myinputbox.focus();甚至myinputbox.select; none会将焦点跳转到我选择的输入字段!任何想法?

Hello, got my code to capture when the Enter key is pressed, however, I'm trying to then set focus on another input box after the enter key capture. I've tried so many variations to set a focus on a certain element after the key is pressed with no luck. I've tried - InputBox.focus, - myinputbox=id("InputBox"); myinputbox.focus(); and even myinputbox.select; none will jump the focus to my selected input field! Any Ideas?

这应该很简单,我似乎无法将文本字段输入到"聚焦/就绪"用于在普通浏览器中通过手动.focus命令输入。我只是忽略了什么?

This should be very simple, I just can't seem to get a text field input to" focus/ready" for input by a manual .focus command as I can in a normal browser. am I just overlooking something?

这里解释了这个方法 - http://msdn.microsoft.com/en-us/library/windows/apps/hh453187.aspx

the method is explained here - http://msdn.microsoft.com/en-us/library/windows/apps/hh453187.aspx

然而,它似乎不起作用。

however, It does not seem to work.

推荐答案

Hi Web,

Hi Web,

您可以分享您的代码吗? 像这样的代码很有用!

Can you share your code?  Code like this works just ducky!

(function () {
    'use strict';
    // Uncomment the following line to enable first chance exceptions.
     Debug.enableFirstChanceException(true);

    function btnClick() {
            Text2.focus();
    }

    WinJS.Application.onmainwindowactivated = function (e) {
        if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
            document.getElementById("Button1").addEventListener("click", btnClick, false);
            

        }
    }

    WinJS.Application.start();
})();




-Jeff


-Jeff


这篇关于element.focus()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆