0

我想循环遍历 div 中的所有(输入和选择)元素并检查该值是否为空,然后将其隐藏

我已经尝试过了,但它不起作用:

$("#tabspanel").find('input[type=text] , select').each(function (){
    if (!(jQuery.trim(this.value).length > 0)) {
        this.hide();
    }
});
4

1 回答 1

3

你应该用过$(this).hide(). 但是,我建议先过滤元素:

$("#tabspanel :input").filter(function() {
    return $.trim(this.value).length === 0;
}).hide();
于 2013-02-15T23:57:53.307 回答