我想根據用戶輸入來計算一個字符串,並顯示一些消息:否則,如果在JavaScript
$('#myInput').keyup(function() {
if(this.value.length<=158)
$('#charCount').text('We will deduct 1 credit from your account');
else if(this.value.length>158 || this.value.length<316)
$('#charCount').text('We will deduct 2 credit from your account');
else if(this.value.length>316 || this.value.length<400)
$('#charCount').text('We will deduct 3 credit from your account');
});
的問題是最後else if
是不工作...我有錯過了什麼?
''||應該是''&&其他 –
問題是,如果你有長度的316不會在任何'if'聲明輸入文本。 –