I am trying to disable checkbox elements on GPA Calculator App using jQuery
The checkbox is created dynamically when adding a new course to indicate if the student has repeated the course in order to fill his previous grade on it:
if(hourSum < 21){
$("<div class='course'>"
+ "<div class='tdnum'>"
+ "<span class='subNum' id='subNum" + i + "'>" + i + " </span>"
+ "</div>"
+ "<div class='tdgrade'>"
+ "<span class='requiredMsg' id='markReq" + i + "'>*</span>"
+ "<input type='number' class='mark'>"
+ "<span class='errorMessage' id='markError" + i + "'>* between 35 - 100</span>"
+ "</div>"
+ "<div class='tdhour'>"
+ "<span class='requiredMsg' id='shourReq" + i + "'>*</span>"
+ "<input type='number' class='shour'>"
+ "<span class='errorMessage' id='shourError" + i + "'>* between 1 - 3</span>"
+ "</div>"
+ "<div class='tdrep'>"
+ "<input id='subState" + i + "' class='repSub' type='checkbox'>"
+ "</div>"
+ "<div class='tdpgrade'>"
+ "<input type='number' class='rmark' id='rmark" + i + "' disabled>"
+ "<span class='errorMessage' id='rmarkError" + i + "'>* between 35 - 100</span>"
+ "</div>"
+ "<div class='tddelete'>"
+ "<span class='remove'><img src='img/delete.png'></span>"
+ "</div>"
+ "</div>").appendTo(".ctable").hide().fadeIn(300); // add fade effect on adding elements
i++;
}
I need to disable this checkbox of class .repSub
when number of passed hours = 0 and overall average = 0
"<input id='subState" + i + "' class='repSub' type='checkbox'>"
I tried this method:
$(".repSub").prop("disabled", true);
also I tried :
$('.repSub').attr("disabled", 'disabled');
but both methods aren't working on dynamically created checkbox
is there any worked solution for this problem ?
Aucun commentaire:
Enregistrer un commentaire