我想使用人性化库和 Jquery 将标题大小写形式的输入。到目前为止我有这个:
$("#FirstName,#LastName").blur(function () {
Humanize.titleCase( $(this) )
});
但它给了我一个错误:
humanize.min.js:2 Uncaught TypeError: n.split is not a function
at o (humanize.min.js:2)
at Object.titleCase (humanize.min.js:2)
at HTMLInputElement.<anonymous> (<anonymous>:3:14)
at HTMLInputElement.dispatch (jquery-2.2.4.min.js:3)
at HTMLInputElement.r.handle (jquery-2.2.4.min.js:3)
最佳答案
Humanize.titleCase( $(this) )
应该是
Humanize.titleCase( $(this).val() );
@vlaz 评论后更新
完整的代码应该是这样的
$("#FirstName,#LastName").blur(function () {
$(this).val( Humanize.titleCase( $(this).val() ) );
});
关于javascript - 人性化输入javascript jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52397865/