zoukankan      html  css  js  c++  java
  • JS Enter键跳转 控件获得焦点

    //回车跳转
    jQuery(document).ready(function () {
    //$(':input:text:first').focus();
    jQuery(':input:enabled').addClass('enterIndex');
    // get only input tags with class data-entry 
    textboxes = jQuery('.enterIndex');
    // now we check to see which browser is being used 
    if (jQuery.browser.mozilla) {
    jQuery(textboxes).bind('keypress', CheckForEnter);
    } else {
    jQuery(textboxes).bind('keydown', CheckForEnter);
    }
    });
    
     
    
     
    
    function SetControlEnterEvent() {
    //$(':input:text:first').focus();
    $(':input:enabled').addClass('enterIndex');
    // get only input tags with class data-entry 
    textboxes = $('.enterIndex');
    // now we check to see which browser is being used 
    if ($.browser.mozilla) {
    $(textboxes).bind('keypress', CheckForEnter);
    } else {
    $(textboxes).bind('keydown', CheckForEnter);
    }
    }
    
    function CheckForEnter(event) {
    if (event.keyCode == 13 && $(this).attr('type') != 'button' && $(this).attr('type') != 'submit' && $(this).attr('type') != 'textarea' && $(this).attr('type') != 'reset') {
    var i = $('.enterIndex').index($(this));
    var n = $('.enterIndex').length;
    if (i < n - 1) {
    if ($(this).attr('type') != 'radio') {
    NextDOM($('.enterIndex'), i);
    }
    else {
    var last_radio = $('.enterIndex').index($('.enterIndex[type=radio][name=' + $(this).attr('name') + ']:last'));
    NextDOM($('.enterIndex'), last_radio);
    }
    }
    return false;
    }
    }
    function NextDOM(myjQueryObjects, counter) {
    if (myjQueryObjects.eq(counter + 1)[0].disabled) {
    NextDOM(myjQueryObjects, counter + 1);
    }
    else {
    myjQueryObjects.eq(counter + 1).trigger('focus');
    }
    }
  • 相关阅读:
    Extjs renderer函数
    孩子,教育,钱
    《新概念英语》的学习方法
    英语,想说爱你爱的太晚
    window.open模拟表单POST提交
    Extjs 解决grid分页bug问题
    Extjs 判断对象是非为null或者为空字符串
    linux shell 删除满足正则表达式的文件
    OpenCV 生成矩形mask
    测试Kaggle kernel commit 是否会删除以前的output
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/3245050.html
Copyright © 2011-2022 走看看