我不确定为什么下面的代码不会将我的两个div隐藏在我的内容中。有人可以检查我的代码吗?该代码不隐藏下面的任何div。谢谢隐藏部门内部的div
好的,这是我编辑的代码。在初始化载入时,这两个表单都出现在选择的类型下,当我选择经销商/客户时,正确的表单显示并选择类型,然后在选择一个后显示为Nothing。我如何才能最初隐藏所有内容?谢谢
<div id="contentArea">
<form action="xxxxx.php" method="post" onsubmit="return checkStuff();" enctype="multipart/form-data">
Warranty Registration Type:<br/>
<select id="select">
<option value ="#blank">Select Type</option>
<option value ="#dealerform">Dealer</option>
<option value ="#customerform">Customer</option>
</select>
<br/>
<br/>
<div id="dealerform">
Dealer Name: <input type="text" name="dealername"> <br/>
Dealer Address: <input type="text" name="dealeradd"> <br>
</div>
<div id="customerform">
First Name: <input type="text" name="firstname"> <br>
Last Name: <input type="text" name="lastname"> <br>
</div>
<script>
$(document).ready(function(){
$('#select').change(function(){
$('#dealerform,#customerform').hide();
$($(this).find('option:selected').attr('value')).show();
});
});
</script>
' $('#select')'应该是'$('select')' – SRy 2013-04-07 05:35:27
您的HTML标记无效。 – Eli 2013-04-07 05:37:19