我不知道我的代碼是否正確,但我想對特定元素運行一些檢查,但我的計數器不工作 - 我的字段沒有隱藏。我如何查找,然後有一個回調函數
//get all fields, some could be text, text area, checkbox, radio...
$(".my-field").each(function(i) {
var wrapper = this;
//check if the text box has a vaule, this callback here is not working/ correct?
$(wrapper).find("input:text", function() {
if ($(this).val() != "" || $(this).val().length > 0) {
hidden++;
$(wrapper).find(".field-content").hide();
$(wrapper).addClass("hide");
} else {
visible = visible + 1;
}
});
});
下面我的HTML是1 字段(如下所示一個格)它們全部包裹與其他領域
<div data-field-type="Text" data-field-id="1" class="display-wrapper my-field">
<div class="field-header">
<span>name:
xyz</span> | <span>
text field</span>
</div>
<div class="field-content">
<div class="editor-label">
<p class="clear">
some description...</p>
</div>
<div class="editor-field">
<input type="text" value="iojhiojio" name="1" maxlength="100" id="field-1" class="field-bigtext">
</div>
<br>
</div>
<div style="display: none;" class="field-error-wrapper">
</div>
</div>
我的問題一個div內,這可能與jquery:
$(wrapper).find("input:text", function() {
.. some code
});
包裝也沒有在給定的代碼中定義。 – 2012-03-01 11:09:42