This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                6年前关闭。
            
                    
我需要从表单输入中获取一个值。将其保存到var。获取用户输入的长度。我收到的不是字符数,而是undefined。两个警报均返回相同的undefined。为什么?

var aisbn = $('#aisbn').val();
alert(aisbn.lenght);
alert(aisbn.toString().lenght);

最佳答案

JavaScript不会自动进行拼写检查。

更改:

alert(aisbn.lenght);


至:

alert(aisbn.length);

09-12 00:41