问题
I have been using jquery in my web based Asp.net MVC application, and when i use chrome mobile to test my work i found that jquery's functions which are based upon keypress/keyup is not working.
I didn't know why it is not working on mobile browsers. It is working properly on desktop browsers.
Can anyone solve my problem, thanks in advance.
回答1:
This worked for me: http://www.dotnetfunda.com/forums/show/8137/onkeyup-event-not-firing-in-firefox-and-chrome
The code:
<textarea name="textarea" id="txtComments" rows="3" onkeyup='return fnMaxLength(this,"5");' style="width: 940px" ></textarea>
function fnMaxLength(field, maxChars) {
if (field.value.length >= maxChars) {
var object = "-More than " + maxChars + " characters have been entered.";
//errorAlert("error", "Maximum length error", object);
alert(object);
return false;
}
}
来源:https://stackoverflow.com/questions/48668105/keypress-keyup-is-not-working-on-chrome-mobile-browser