Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检测元素何时将获得焦点_Javascript_Jquery_Asp.net_Focus_Radeditor - Fatal编程技术网

Javascript 检测元素何时将获得焦点

Javascript 检测元素何时将获得焦点,javascript,jquery,asp.net,focus,radeditor,Javascript,Jquery,Asp.net,Focus,Radeditor,我有一个带有Telerik RadEditor(富文本框)的ASP.NET页面。当用户在页面中使用Tab键时,当用户进入文本框时,焦点会在进入文本区域之前设置为各种工具栏图标。我在一个页面中添加了一些jQuery,以便在从表单的最后一个单元格中移出时将焦点设置在文本区域上: $('input[type=text][id*=tbCost]').keydown(function (e) { var keyCode = e.keyCode || e.which; if (keyCode

我有一个带有Telerik RadEditor(富文本框)的ASP.NET页面。当用户在页面中使用Tab键时,当用户进入文本框时,焦点会在进入文本区域之前设置为各种工具栏图标。我在一个页面中添加了一些jQuery,以便在从表单的最后一个单元格中移出时将焦点设置在文本区域上:

$('input[type=text][id*=tbCost]').keydown(function (e) {
    var keyCode = e.keyCode || e.which;
    if (keyCode == 9) {    //If TAB key was pressed
        e.preventDefault();
        var editor = $('body').find("<%=RadEditor1.ClientID%>");    //get a reference to RadEditor client object
        editor.setFocus();    //set the focus on the the editor
    }
});

您可以考虑绑定到工具栏图标,并将焦点重定向到文本区域。尽管如果用户试图使用这些工具,这可能会产生意想不到的副作用

    //on focus eventHandler for all your icons that calls a function


  #('.elementtype, class or a generic way of identifying the icons'.onfocus(myFunction(this))
//函数获取元素的一个参数,移动到下一个同级元素并设置焦点

     myFunction = (element) {
       element.next().focus();
     }

为什么不将焦点设置在
keyup()
?可以使用JQuery的“bind”或“on”方法将此特定代码绑定到所有输入[type=text]elements@rnirnber我认为在上使用
可以奏效。当工具栏(
.reToolCell
)获得焦点时,我可以这样做来转移焦点吗?:
$('.reToolCell').on('focus',function(){var editor=$(this).find(“”;editor.setFocus();})嗯,“$find”应该是$(这个)。find…但是除了它看起来不错之外,我一直都在做类似的事情。我同意如果用户试图将焦点锁定到工具栏上,可能会导致问题,但是看起来这样做总体上是可行的。谢谢
     myFunction = (element) {
       element.next().focus();
     }