I am trying to hide a div based on a input check value. Also it should work if the item is already checked, so far my code is not working. As the div I want to hide always shows? I have created a JS Fiddle to replicate the issue
The code is as follows:
var test = $("input[value='home']");
if (test == true) {
$(".title").hide();
} else {
$(".title").show();
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div role="radiogroup">
<input type="radio" name="gender" value="home" checked> Male
<br>
<input type="radio" name="gender" value="female"> Female
<br>
<input type="radio" name="gender" value="other"> Other
<br />
<br />
<div class='title'>
This is the title not on home value
</div>
</div>
Any input would be great.