您好!基本上,我希望在点击复选框时出现一个文本框,在取消点击时消失。这是JSFiddlehttp://jsfiddle.net/GBSZ8/2/而且效果很好。但是,当我将其保存为check.php时,即使单击复选框,文本框也不会出现。
<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>
请帮帮我。谢谢!
您必须在文件中包含JQuery。放入
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
在你的第一个标签上方。
请随意更改相应的版本号或调整url以转到jquery.js文件的本地版本
您可能需要将其封装在onLoad以及Paarth的答案中。
$(document).ready(function() {