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 = "";
})
}
しかし、何も起こらない...だから、セレクターを正しくしてはいけません。私が間違ったことを誰かが見ていますか?