I have the following code that was suggested to me earlier today:
$(window).keypress(function (e)
{
if (e.keyCode 开发者_StackOverflow中文版== 13)
{
$('#doCheck').focus().click();
}
});
One user in another post said that this would make a button appear to animate and be clicked. When I tried it does have some effect but at least in Firefox it still does not make the button appear as though it's being clicked. Has anyone been able to make a button look like it's physically clicked with jQuery?
On execution, you would need to switch classes to make the button look pressed, then you would need to setInterval for a few milliseconds and once fired change the class back to a regular looking button.
just change the border...an unclicked button generally has an outset border, when you click it, it changes to inset so:
$(window).keydown(function (e)
{
if (e.keyCode == 13)
{
$('#doCheck').css({borderStyle:'inset'});
}
});
$(window).keyup(function (e)
{
if (e.keyCode == 13)
{
$('#doCheck').css({borderStyle:'outset'});
$('#doCheck').focus().click();
}
});
精彩评论