Jump to content
Sign in to follow this  

can someone help me on solving this? the jquery shoculd focus on all div elements..not only on a particular div

Recommended Posts

i want my code to be work as when i press arrowkey at checkbox 4, it should focus the submit button element in the next div. but now it is focusing the first checkbox.How to modify it?




<!DOCTYPE html>
        <title>Page Title</title>
        <script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<input type="checkbox"  autofocus/>1
<input type="checkbox" />2
<input type="checkbox" />3
<input type="checkbox" />4
<input type="button" value="mycheckbox">
<input type="button" value="mycheckbox">

 $(document).ready(function () {
    $('input').keydown(function (event) {
        var keycode = (event.keyCode ? event.keyCode : event.which);
        if (keycode == 13) {

        if (keycode == 39) {
            if($(this).nextAll('input').length === 0) {
              $('input:enabled:first').focus();// first textbox
if (keycode ==37) {
            if($(this).prevAll('input').length === 0) {


function clickCheckBox(box) {
    var $box = $(box);


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...