I have these three divs which I am trying to make at least 2 of them to work first. All divs are disabled from the start. if the 1st div is clicked, the div will be enabled with all it's inputs and so on. if 1st div is not enabled, the 2nd and 3rd div cannot be enabled. if 1st div is clicked which enables it then the 2nd div can be enabled or disabled. if both 1st and 2nd div is enabled then 1st div is clicked which disables it then the 2nd div will be disabled too.
right now what I am able to do is if I enable the 1st div I can then enable the 2nd div but somehow if I disable the 1st div the 2nd div still can be enabled / disabled by itself but what I want is without having 1st div to be enabled 2nd div cannot be enabled at all and this will go on to the 3rd div and maybe more later.
Can people give me a hand to see what I should change in my code for this to work?
$(twoSides).on('click', function(e){
e.preventDefault();
var disabledAttr = $(twoSides).attr('disabled');
if(disabledAttr == 'disabled'){
enableSides(twoSides,dimensionSideB,colorSideB,mountSideB);
// if three sides is clicked
$(threeSides).on('click', function(e){
e.preventDefault();
var disabledAttr = $(threeSides).attr('disabled');
if(disabledAttr == 'disabled'){
enableSides(threeSides,dimensionSideC,colorSideC,mountSideC);
console.log(disabledAttr);
console.log('three enabled');
}else{
disableSides(threeSides,dimensionSideC,colorSideC,mountSideC);
console.log(disabledAttr);
console.log('three disabled');
}
});
}else{
disableSides(twoSides,dimensionSideB,colorSideB,mountSideB);
disableSides(threeSides,dimensionSideC,colorSideC,mountSideC);
}
});
Thanks thanks in advance.
EDIT Sorry I left out the most important part. other than the divs, the divs have other divs that isn't child might be siblings or even deeper divs that's in the same column that when clicked div1 the same column would then be enabled / disabled