Inside my Content page I have a repeater control, which contains multiple controls along with a lable. The Id of lable is “LEmptyComments“. My requirement is to check if the class name of the label is empty or not. The If block never executes what am I doing wrong?
function chkCmnts() {
var val = 1;
$("label[id*='LEmptyComments']").each(function () {
if ($(this).className != "") {
val = 0;
return val;
}
});
return val;
}
This is how the lable look like in the HTML page :
<span id="MainContent_DlReviewImages_LEmptyComments_13" class="error">...... </span>
classNameis not a valid jQuery function or property, however you’re calling it on a jQuery object. Additionally, you’re looping overlabels and notspans:You could actually replace this entire thing with one jQuery statement and a conditional operator on the
lengthof that statement:Example: http://jsfiddle.net/LLKbP/