I'm new in Javascript and Jquery, so I'm having a problem.
Here is a code which checks if three checkboxes are checked, and at last - condition- if all of those three are checked, show an html element.
$('input[class^="class"]').click(function() { var $this = $(this);
if ($this.is(".class1")) {
if ($this.is(":checked")) {
$(".class1").not($this).prop({ disabled: true, checked: false });
$(".class").prop("checked", true);
setTimeout(function() { $('#2').click(); }, 1000); //oncheck moves to the next question
var questionOne = 1;
} else {
$(".class1").prop("disabled", false);
}
}
if($this.is(".class2")) {
if ($this.is(":checked")) {
$(".class2").not($this).prop({ disabled: true, checked: false });
$(".class").prop("checked", true);
setTimeout(function() { $('#3').click(); }, 1000);
var questionTwo = 1;
} else {
$(".class2").prop("disabled", false);
}
}
if($this.is(".class3")) {
if ($this.is(":checked")) {
$(".class3").not($this).prop({ disabled: true, checked: false });
$(".class").prop("checked", true);
setTimeout(function() { $('#4').click(); }, 1000);
var questionThree = 1;
} else {
$(".class3").prop("disabled", false);
}
}
if(questionOne = 1 && questionTwo = 1 && questionThree = 1) { alert("alert on Page load"); }
});
I guess the problem is either in setting variables or in the last condition.
Thanks in advance! Best Regards, Joni
Aucun commentaire:
Enregistrer un commentaire