<分区>
我需要从表单输入中获取一个值。将其保存到 var。获取用户输入的长度。我收到的不是字符数 undefined
。两个警报都返回相同的 undefined
。为什么?
var aisbn = $('#aisbn').val();
alert(aisbn.lenght);
alert(aisbn.toString().lenght);
标签 javascript jquery
<分区>
我需要从表单输入中获取一个值。将其保存到 var。获取用户输入的长度。我收到的不是字符数 undefined
。两个警报都返回相同的 undefined
。为什么?
var aisbn = $('#aisbn').val();
alert(aisbn.lenght);
alert(aisbn.toString().lenght);
最佳答案
JavaScript 不会自动进行拼写检查。
改变:
alert(aisbn.lenght);
收件人:
alert(aisbn.length);
关于javascript - 字符串长度未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15930955/