【发布时间】:2015-09-17 04:44:57
【问题描述】:
我得到了这个脚本,它在小提琴上运行得非常好,但在我的网站上却不行。
现场代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$(".hiddenInput").hide();
$(".showHideCheck").on("change", function() {
$this = $(this);
$input = $this.parent().find(".hiddenInput");
if($this.is(":checked")) {
$input.slideDown();
} else {
$input.slideUp();
}
});
</script>
</head>
<body>
<form>
<div class="option">
<input type="checkbox" name="chkBox1" id="chkBox1" class="showHideCheck" />Click me to show the text box
<br/><div class="hiddenInput"> Enter
<input type="text" name="txtBox1"/></div>
</div>
<div class="option">
<input type="checkbox" id="chkBox2" name="chkBox2" class="showHideCheck" />Click me to show the text box
<br/><div class="hiddenInput">Enter
<input type="text" name="txtBox2"/></div>
</div>
</form>
</body>
</html>
【问题讨论】:
-
你在 js 控制台中遇到什么错误?
-
“不工作”不是对问题的描述。请阅读:minimal reproducible example
标签: javascript jquery html