Why clicking on the male radio button does not work?
<div id="m_wrapper">
<input id="m" type="radio" name="sex" value="male" />Male<br>
</div>
<input id="f" type="radio" name="sex" value="female" />Female
<input id="o" type="radio" name="sex" value="other" />Other
$("#m_wrapper").click(function(e){
$("#m").prop('checked', true);
return false;
});
I know that here -> return false is equivalent to call e.preventDefault() AND e.stopPropagation()
However, when I click on the radio button, I have an explicit line setting the property checked to true for the Male radio button. Why will preventDefault() will UNDO something I set?
By the way, clicking anywhere inside 'm_wrapper' checks the radio button. Which makes sense.
I know that removing return false will fix the issue. The question is 'why?'
$("#m_wrapper").click(function(e){
$("#m").prop('checked', true);
return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div id="m_wrapper">
<input id="m" type="radio" name="sex" value="male" />Male<br>
</div>
<input id="f" type="radio" name="sex" value="female" />Female
<input id="o" type="radio" name="sex" value="other" />Other