我試圖使用jQuery做一個簡單的事情:明確一個div中的一組輸入欄的輸入字段時加載窗體,或者如果用戶更改選擇列表;但我有一個讓選擇器工作的時間。如何用jQuery清除特定div中的所有輸入字段?
首先,這是我的onclick和onload事件觸發:
<form name="EditGenotype" action="process_GenotypeMaint.php" method="POST" onsubmit="return false" onload=clear_fetch() >
,並在領料:
<SELECT multiple size=6 NAME="marker" onchange=show_marker() onclick=clear_fetch() >
接下來,這裏是在div我的HTML輸入元素我想清楚了:
<div class=fetch_results>
<fieldset>
<LEGEND><b>Edit Genotype, call 1</b></LEGEND>
<boldlabel>Allele_1</boldlabel><input id=allele_1_1 name=allele_1_1 size=5 >
<boldlabel>Allele_2</boldlabel><input id=allele_1_2 name=allele_1_2 size=5 >
<boldlabel>Run date</boldlabel><input id=run_date1 name=run_date1 size=10 disabled=true>
</fieldset>
<fieldset>
<LEGEND><b>Edit Genotype, call 2</b></LEGEND>
<boldlabel>Allele_1</boldlabel><input id=allele_2_1 name=allele_2_1 size=5 >
<boldlabel>Allele_2</boldlabel><input id=allele_2_2 name=allele_2_2 size=5 >
<boldlabel>Run date</boldlabel><input id=run_date2 name=run_date2 size=10 disabled=true>
</fieldset>
<fieldset>
<LEGEND><b>Edit Genotype, call 3</b></LEGEND>
<boldlabel>Allele_1</boldlabel><input id=allele_3_1 name=allele_3_1 size=5 >
<boldlabel>Allele_2</boldlabel><input id=allele_3_2 name=allele_3_2 size=5 >
<boldlabel>Run date</boldlabel><input id=run_date3 name=run_date3 size=10 disabled=true>
</fieldset>
</div>
最後,這裏是我的腳本:
function clear_fetch() {
$('#fetch_results:input', $(this)).each(function(index) {
this.value = "";
})
}
然而,什麼也沒有發生......所以,我不能有選擇是正確的。有人看到我做錯了嗎?
謝謝!這很好! – rixter
SELECT選項如何? – Si8
如果您有任何建議,請隨時添加建議,但這不是所有方法的完整答案。 – Peter