.... 的标签不是 select 它的输入(有时)
label for .... not select its input ( sometimes )
这是非常非常罕见的事情,但有时,当我 select 一个标签时,它的输入不是 selected。
我有 html 喜欢:
<td class="pleno_al_15 impar">
<label class="label_radio label_pleno activo" for="partido15-jugada1-cero" title="partido15-jugada1-cero">0</label>
<input class="radio_hidden" id="partido15-jugada1-cero" name="bets[0][14][0]" title="partido15-jugada1-cero" type="checkbox" value="0">
<label class="label_radio label_pleno activo" for="partido15-jugada1-uno" title="partido15-jugada1-uno">1</label>
<input class="radio_hidden" id="partido15-jugada1-uno" name="bets[0][14][1]" title="partido15-jugada1-uno" type="checkbox" value="1">
<label class="label_radio label_pleno activo" for="partido15-jugada1-dos" title="partido15-jugada1-dos">2</label>
<input class="radio_hidden" id="partido15-jugada1-dos" name="bets[0][14][2]" title="partido15-jugada1-dos" type="checkbox" value="2">
<label class="label_radio label_pleno activo" for="partido15-jugada1-m" title="partido15-jugada1-m">M</label>
<input class="radio_hidden" id="partido15-jugada1-m" name="bets[0][14][3]" title="partido15-jugada1-m" type="checkbox" value="M">
</td>
我通过使用 javascript 处理事件解决了它。
首先,我想更好地解释一下发生在我身上的事情。
我隐藏了输入标签,以便用户只能 select 标签标签(图像),而不是输入标签。所以,有时,labels 标签没有激活其对应的输入标签。
我通过添加这个解决了它:
$(".radio_hidden").bind("change", function () {
$("#jab_contenido .label_radio").each(function(index, element) {
if ($("#"+$(this).attr("for")).is(":checked")) $(this).addClass("activo");
else $(this).removeClass("activo");
});
});
上面的代码处理输入标签的更改事件,并查找 add/remove class 对应的标签以显示图像 ( on/off )。 因此只有在输入标签被真正选中时才会显示上图。
希望对您有所帮助
这是非常非常罕见的事情,但有时,当我 select 一个标签时,它的输入不是 selected。 我有 html 喜欢:
<td class="pleno_al_15 impar">
<label class="label_radio label_pleno activo" for="partido15-jugada1-cero" title="partido15-jugada1-cero">0</label>
<input class="radio_hidden" id="partido15-jugada1-cero" name="bets[0][14][0]" title="partido15-jugada1-cero" type="checkbox" value="0">
<label class="label_radio label_pleno activo" for="partido15-jugada1-uno" title="partido15-jugada1-uno">1</label>
<input class="radio_hidden" id="partido15-jugada1-uno" name="bets[0][14][1]" title="partido15-jugada1-uno" type="checkbox" value="1">
<label class="label_radio label_pleno activo" for="partido15-jugada1-dos" title="partido15-jugada1-dos">2</label>
<input class="radio_hidden" id="partido15-jugada1-dos" name="bets[0][14][2]" title="partido15-jugada1-dos" type="checkbox" value="2">
<label class="label_radio label_pleno activo" for="partido15-jugada1-m" title="partido15-jugada1-m">M</label>
<input class="radio_hidden" id="partido15-jugada1-m" name="bets[0][14][3]" title="partido15-jugada1-m" type="checkbox" value="M">
</td>
我通过使用 javascript 处理事件解决了它。
首先,我想更好地解释一下发生在我身上的事情。 我隐藏了输入标签,以便用户只能 select 标签标签(图像),而不是输入标签。所以,有时,labels 标签没有激活其对应的输入标签。
我通过添加这个解决了它:
$(".radio_hidden").bind("change", function () {
$("#jab_contenido .label_radio").each(function(index, element) {
if ($("#"+$(this).attr("for")).is(":checked")) $(this).addClass("activo");
else $(this).removeClass("activo");
});
});
上面的代码处理输入标签的更改事件,并查找 add/remove class 对应的标签以显示图像 ( on/off )。 因此只有在输入标签被真正选中时才会显示上图。
希望对您有所帮助