私は "PERS" を示し、 "バス" と、その逆別のラジオボタンを押したときにラジオボタンイベントがトリガーされるのはなぜですか?
のjQueryを非表示にするには、次のコードを使用しています:
$('input[name="perorbus"]').click(function() {
if ($(this).attr('id') == 'bus') {
$('#showbus').show();
$('#showper').hide();
}
if ($(this).attr('id') == 'pers') {
$('#showper').show();
$('#showbus').hide();
}
});
HTML:
<fieldset id="perorbus">
<label style="font-size: large;">Personal Or Business?</label>
<br/>
<input type="radio" class="PerOrBus" value="pers" id="pers" name="perorbus"/>
<label style="font-size: medium;">Personal Customer</label>
<input type="radio" class="PerOrBus" id="bus" value="bus" name="perorbus"/>
<label style="font-size: medium;">Business Customer?</label>
<br/>
</fieldset>
<table id="showper">
<tr>
<td>Show Personal</td>
</table>
<table id="showbus">
<tr>
<td>Show Business</td>
</table>
私が置かれた任意の他のラジオボタンページ上でこれがトリガーされます。これらはすべて、次のようにname属性を与えられている:
<fieldset id="CACCc">
<input type="radio" id="1b" class="2b" value="4b" name="1b"/> Yes
<br/>
<input type="radio" id="id12" class="4class" value="4c" name="id12"/> No
<br/></fieldset>
をしかし、私は次のようにjQueryを使って準備ができてドキュメントに名前を割り当てる必要があり:
document.getElementById("1b").setAttribute('name', '1b');
document.getElementById("id12").setAttribute('name', 'id12');
これは私は、限定されることによるものです名前を使用しないと
すべてのヘルプは素晴らしいことだ、感謝
これをフィドルで再現できますか? (https://jsfiddle.net/k7knjypu/はうまくいきます) – Florian
真、別の場所の問題である必要があります – Stacker