是否可以在选择器中进行修剪? [英] Is it possible to make trim in a selector?
本文介绍了是否可以在选择器中进行修剪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想计算表单中所有空的输入。对于空,我的意思是在修剪其值后它的值为空(如果用户插入空白也是空的)。
这个jquery计算它们,但它不包括修剪:
I'd like to count all the inputs in my form which are empty. With empty I mean that its value is empty after trimming its value (if the user insert whitespaces its empty as well). This jquery count them, but it doesn't include the trimming:
$(':text').filter('[value=""]').length
有什么jquery可用于在选择器中修剪?
Has something jquery which can be used to trim in the selector?
谢谢
推荐答案
$(':text').filter(function () {
return $.trim($(this).val()).length === 0;
});
这篇关于是否可以在选择器中进行修剪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文