以下是我已经写过的内容,并且运行良好:
var $remaining = $('#remaining'),
$messages = $remaining.next();
$('#message').keyup(function(){
var chars = this.value.length,
messages = Math.ceil(chars / 160),
remaining = messages * 160 - (chars % (messages * 160) || messages * 160);
$remaining.text(remaining + ' characters remaining');
$messages.text(messages + ' message(s)');
}); 这是上面的代码
现在我想做的是:
var text_max_En = 100;
var text_max_utf8 = 200;
if /* what user has typed is English */
{
Do this
}
else if /* what user has typed is in utf8 type*/
{
Do that
}
简而言之 :
**If**
用户在此处输入英文,则每条消息最多应计为 100 个字符
AND **if**
那是 urf8 类型,那么它应该最多计数 200 个。
有什么解决办法吗?