Home  >  Article  >  Web Front-end  >  在input 中按回车如何把焦点定位到linkbutton上?_html/css_WEB-ITnose

在input 中按回车如何把焦点定位到linkbutton上?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:45:361219browse

代码如下:    
    $( '#password').textbox('textbox' ).keydown(function (e) {
                if (e.keyCode == 13) {
                   $( "#login").linkbutton('linkbutton' ).focus();
                }
            });  


回复讨论(解决方案)

      
        

  
            change focus  
          
          
            
  
                  
                      
                          
                      
                      
                          
                      
                
Username:
Password:
  
            
  
          
      
    <script> <br /> var usernameObj = document.getElementById("username"); <br /> usernameObj.onkeydown = function(event) { <br /> e = event ? event :(window.event ? window.event : null); <br /> // 按下回车键且输入框值非空时 <br /> if(e.keyCode==13 && usernameObj.value){ <br /> document.getElementById("password").focus(); <br /> } <br /> } <br /> </script>    

参考 http://blog.csdn.net/magi1201/article/details/45177113

focus()是jquery对象的方法,
$( "#login").linkbutton('linkbutton' )返回的不是jquery对象

我猜应该是这样:$( "#login").focus()

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn