I have two products, if I select ProductA I want the "Add" button to hide, but if I choose ProductB I want both buttons to show again.
How do I achieve that?
<input id="option1" value="ProductA" name="radio-group" type="radio">
<label for="option1" class="radio-custom-label">ProductA</label>
<input id="option2" value="ProductB" name="radio-group" type="radio">
<label for="option2" class="radio-custom-label">ProductB</label>
<button id="add">ADD</button>
<button id="buy">BUY</button>
<script>
const value = document.querySelector('input[name="radio-group"]:checked').value;
if(value === 'ProductA'){
document.getElementById('add').style.display = 'none';
}else{
document.getElementById('add').style.display = 'block';
}
</script>
2
Answers
If I understood correctly, see if this is what you want
you can simply use some CSS…