javascript tab key problem? in textbox
Why doesnt work this code one safari,chrome and internet explorer.. Only works with Opera and Firefox...
$("#txtAd").keypress(function (e) {
var code = e.keyCode || e.which;
if (code == 9) {
$("#txtSoyad").val(开发者_高级运维'');
};
});
jQuery abstracts that so you don't have to :)
To determine which character was entered, examine the event object that is passed to the handler function. While browsers use differing properties to store this information, jQuery normalizes the
.which
property so you can reliably use it to retrieve the character code.
Source.
Use e.which
, no need to use ||
short circuit evaluation trick.
Though in saying that, your code did work for me in Chrome 10.
Are you sure $("#txtSoyad")
is a valid selector, and has selected what you want? Output the length
property, if you don't see 1
, it isn't selecting it correctly.
精彩评论