You can use prop function to set "checked" property:
<script>
$(document).ready(function()
{
$('#bar1').prop('checked', true);
$('#radiobar1').prop('checked', true);
});
</script>
Working Example
<!DOCTYPE html>
<html lang="en">
<head>
<style>
#hiddenElement {
display: none;
}
#visibleElement {
display: block;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script>
$(document).ready(function()
{
$('#bar1').prop('checked', true);
$('#radiobar1').prop('checked', true);
});
</script>
</head>
<body>
<div>
<input type="checkbox" name="foo1" value="bar1" id="bar1" />
<input type="checkbox" name="foo1" value="bar2" id="bar2" />
<input type="checkbox" name="foo1" value="bar3" id="bar3" />
</div>
<div>
<input type="radio" name="foo2" value="bar1" id="radiobar1" />
<input type="radio" name="foo2" value="bar2" id="radiobar2" />
<input type="radio" name="foo2" value="bar3" id="radiobar3" />
</div>
</body>
</html>