I have a simple bit of HTML:
<input type="text" id="lk" />
<div id="showDiv">
<input type="radio" name="lki" id="lki1" value="lki1"> <label for="lki1">Anywhere</label>
<input type="radio" name="lki" id="lki2" value="lki2"> <label for="lki2">Start</label>
</div>
// page load
$(document).ready(function () {
var bla = $('#lk').val();
if(bla.length > 0){
$('#showDiv').show();
}
else {
$('#showDiv').hide();
}
});
// show / hide the "showDiv" content when a user types into the #lk text input field
$('#lk').bind('keyup change',function(){
if(this.value.length > 0){
$('#showDiv').show();
}
else {
$('#showDiv').hide();
}
});
// page load
$(document).ready(function () {
var bla = $('#lk').val();
if(bla.length > 0){
$('#showDiv').show();
}
else {
$('#showDiv').hide();
}
});
I would add this CSS rule to set an initial status where the DIV isn't shown:
#showDiv {
display: none;
}
(That will change depending on the condition in your jQuery function, but this rule will make sure that DIV won't appear for even a milisecond when the page is loaded, before the jQuery function is performed)