Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8827829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:27:54+00:00 2026-06-14T07:27:54+00:00

please consider this codes: I have a table like this: <table class=ArrowNav cellspacing=0 rules=all

  • 0

please consider this codes:

I have a table like this:

<table class="ArrowNav" cellspacing="0" rules="all" border="1" id="GridView1" style="height:302px;width:692px;border-collapse:collapse;">
    <tr>
        <th class="Id" scope="col">Id</th><th scope="col">"Group</th><th scope="col">Value</th>
    </tr><tr>
        <td align="center" valign="middle">1</td><td align="center" valign="middle">1</td><td align="center" valign="middle">100</td>
    </tr><tr>
        <td align="center" valign="middle">2</td><td align="center" valign="middle">1</td><td align="center" valign="middle">120</td>
    </tr><tr>
        <td align="center" valign="middle">3</td><td align="center" valign="middle">1</td><td align="center" valign="middle">100</td>
    </tr><tr>
        <td align="center" valign="middle">4</td><td align="center" valign="middle">2</td><td align="center" valign="middle">90</td>
    </tr><tr>
        <td align="center" valign="middle">5</td><td align="center" valign="middle">2</td><td align="center" valign="middle">105</td>
    </tr><tr>
        <td align="center" valign="middle">6</td><td align="center" valign="middle">3</td><td align="center" valign="middle">300</td>
    </tr><tr>
        <td align="center" valign="middle">7</td><td align="center" valign="middle">4</td><td align="center" valign="middle">123</td>
    </tr><tr>
        <td align="center" valign="middle">8</td><td align="center" valign="middle">4</td><td align="center" valign="middle">110</td>
    </tr><tr>
        <td align="center" valign="middle">9</td><td align="center" valign="middle">5</td><td align="center" valign="middle">100</td>
    </tr><tr>
        <td align="center" valign="middle">10</td><td align="center" valign="middle">5</td><td align="center" valign="middle">110</td>
    </tr>
</table>

and I write a script for navigate between rows :

var SelectedRowIndex;

    $(document).ready(function () {
        $('.ArrowNav tr').first().css('background-color', 'yellow');
        //            $('.ArrowNav tr').first().focus();
        $('.ArrowNav tr:first').first().trigger('click');
        SelectedRow = 0;

        function ResetAllRowColor() {
            $('.ArrowNav tr').each(function () {
                $(this).css('background-color', 'white');
            });
        }

        $('.ArrowNav tr').on('keyup', function (e) {
            ResetAllRowColor();
            switch (e.keyCode) {
                case 40: //Down
                    SelectedRow++;
                    $('.ArrowNav tr').eq(SelectedRow).css('background-color', 'yellow');
                    break;
                case 38: //Up
                    SelectedRow--;
                    $('.ArrowNav tr').eq(SelectedRow).css('background-color', 'yellow');
                    break;
            }
        });

        $('.ArrowNav tr').on('click', function () {
            alert('a');
        });
    });

the problem is for navigating the table must have focus on it.I write this code for set focus: $('.ArrowNav tr').first().focus(); but it didn’t work.I also write this code : $('.ArrowNav tr:first').first().trigger('click'); but click event on rows does not fire.I want in page load I can navigate between rows buy arrow keys. where is the problem?

jsfiddle

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:27:56+00:00Added an answer on June 14, 2026 at 7:27 am

    Scoping & Selecting issue.

    Click event cannot be called before the click function has been defined.

    $('.ArrowNav tr').on('click', function () {
        alert('a');
    });
    $('.ArrowNav tr').eq(0).click();
    

    The keys event up/down cannot be bound to a table because a table cannot gain focus. The document starts with the focus right away, so you can bind the keyup/down event to it.

        $(document).on('keyup', function(e) {
        ResetAllRowColor();
        switch (e.keyCode) {
        case 40:
            //Down
            SelectedRow++;
            $('.ArrowNav tr').eq(SelectedRow).css('background-color', 'yellow');
            break;
        case 38:
            //Up
            SelectedRow--;
            $('.ArrowNav tr').eq(SelectedRow).css('background-color', 'yellow');
            break;
        }
    });​
    

    your working jsFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please Consider this scenario: We have a base class called clsMain : class clsMain
please consider this scenario: I have a list of a class with about 50
please consider this code : 1)public static class MyClass 2){ 3) public static DateTime
please consider this table: PK_Id Number Year Month Value ------------------------------------------------------------------------- 1 1 2000 5
Please consider this -probably poorly written- example : class Command; class Command : public
Please consider the following XML-- <table class=rel_patent><tbody> <tr><td>Name</td><td>Description</td></tr> <tr><td>A</td><td>Type-A</td></tr> <tr><td>B</td><td>Type-B</td></tr> <tr><td>C</td><td>Type-C</td></tr> <tr><td>AC</td><td>Type-C Type-A</td></tr> <tr><td>D</td><td></td></tr>
i have trouble with building some projects. please consider this scenario: i have 2
Please consider the following scenario. I have a form with a property: class MyForm
Please consider the following table structure (this is sample data, so please ignore the
please consider this code : 1-... 2-{ 3-... 4-SqlConnection cn=new SqlConnection(); 5-... 6-} if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.