I could use a help. I'm still new to doing jQuery, and I can get the divs to show when there is no submit button, but when I add the submit button, I can't get the divs based on the radio button.
$(document).ready(function(){
$(".result").click(function(){
$("input[name=expectation]").change(function() {
var expectedValue = $(this).val();
$(".box").hide();
$("#"+ expectedValue).show();
});
});
});
.box {
display:none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="answers">
<input type="radio" name="expectation" id="wavy" value="wavy">
<label for="wavy">for wavy hair</label>
<br>
<input type="radio" name="expectation" id="health" value="health">
<label for="health">for healthy hair</label>
<br>
<input type="radio" name="expectation" id="silky" value="silky">
<label for="silky">make hair silky</label>
<br>
</div>
<button class="result">Submit</button>
<div id="wavy" class="box">Product for Wavy Hair</div>
<div id="health" class="box">Product for Healthy Hair</div>
<div id="silky" class="box">Product for Silky Hair</div>