Reputation: 47
Good day! Basically, I want a textbox to appear when a checkbox is clicked and disappear when unclicked. Here is the JSFiddle http://jsfiddle.net/GBSZ8/2/ and it works just fine. However, when I saved it as check.php, the text box doesn't appear even if I click the checkbox.
<html>
<head>
<script>
$('#supplied').live('change', function(){
if ( $(this).is(':checked') ) {
$('#date').show();
} else {
$('#date').hide();
}
});
</script>
</head>
<body>
<input type="checkbox" name="supplied" id="supplied" value="supplied" class="aboveage2" />
<ul id="date" style="display:none">
<li><input id="start" name="start" size="5" type="text" class="small" value="1" /></li>
</ul>
</body>
</html>
Please help me. Thank you!
Upvotes: 2
Views: 2381
Reputation: 876
You probably need to wrap it in onLoad as well as Paarth's answer.
$(document).ready(function() {
Upvotes: 1
Reputation: 10377
You have to include JQuery in your file. Put
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Above your first tag.
Feel free to change the version number as appropriate or adjust the url to go to a local version of the jquery .js file
Upvotes: 4