且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用JQuery在JavaScript中计算单词

更新时间:2023-11-23 15:30:04

您可以拆分字符串,然后计算结果数组的长度。

You would split the string and then count the length of the resulting array.

$('input[type="submit"]').click( function() {
    var words = $('#name').val().split(' ');
    alert(words.length);
});