0

I have created a Live Search that displays results in a table row. Row has onClick function that executes a process of selecting result. OnClick function works fine by mouse click but I want user can select it by up/down arrow key and Enter too. Now I want function set in onClick is called from other JavaScript function. Any help please......

1
  • do you use jQuery ? if so you could venture into .keypress() Commented Feb 19, 2011 at 2:38

2 Answers 2

2
myElement.onclick = function() {
    // called when myElement is clicked
}

or just

myElement.click(); // clicks the element

And use an onkeydown event to call it, and just check for characters before the click();

myField.onkeydown = function() {
    myElement.click();
}
Sign up to request clarification or add additional context in comments.

Comments

0

try something like this:

$('tr').live({
      click:  function(e)
    {       
        //your code here;
    },
      keyup: function(e)
        {
              // and here;
        }
   })   

it requires jQuery

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.