Call onClick from JavaScript function
I have created 开发者_JAVA技巧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......
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();
}
try something like this:
$('tr').live({
click: function(e)
{
//your code here;
},
keyup: function(e)
{
// and here;
}
})
it requires jQuery
精彩评论