更新: 看着人們的建議,我意識到我應該去沒有AJAX。我決定改變加載函數,現在把jQuery代碼放在裏面。但是,它仍然不起作用,因爲沒有元素顯示爲可見。這是新代碼的樣子。HTML選擇標籤和jQuery顯示和隱藏
<style>
.input_1 {display: none;}
.input_2 {display: none;}
.input_3 {display: none;}
</style>
<script type="text/javascript">
var numbers = $('#select_number').val();
function load(numbers) {
if (numbers == 1)
{$("input").hide();$(".input_1").show();} else
if (numbers == 2)
{$("input").hide();$(".input_1").show();$(".input_2").show();} else
if (numbers == 3)
{$("input").hide();$(".input_1").show();$(".input_2").show();$(".input_3").show();}}
</script>
這裏是選擇標籤貌似現在什麼
<form id="form" action="" method="post">
<select id="select_number" onclick="load(numbers);" >
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<input type="text" class="input_1"/>
<input type="text" class="input_2"/>
<input type="text" class="input_3"/>
</form>
好吧。當我在我想要結果的ajax文件中寫入show()時。我想要的是用戶點擊select標籤中的數字,然後顯示一些元素。所以我應該把我的ajax文件中的show()jquery函數放入函數(data){... – jason328 2012-08-06 02:11:39