I'm having problems with this bit of jquery. When the page loads, id_2 is hidden. If I check the check box id_1 nothing happens. However if I reload the page, id_2 then shows.
<head>
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"> /script>
</head>
<input id="id_1" type="checkbox" name="ck1">
<input type="text" id="id_2" name="tx1">
<script type="text/javascript">
$(document).ready(function() {
if ($('#id_1').is(':checked')) {
($('#id_2').show());
} else {
($('#id_2').hide());
}
});
If I use a button and
$("#show_button").click(function()
it works - id_2 shows/hides correctly. I can see in firebug that when I check the checkbox the checked value toggles from true / false.
What am I doing wrong?
Oli
scripttag