附加的侦听器不应该在复选框旁边的标签上听

时间:2015-10-14 09:40:06

标签: javascript html event-listener

我在Checkbox上附加了一个EventListener。复选框旁边是一个符号(Euro-Symbol)。 Euro-Symbol不应该是可点击的,但是,使用我的代码,复选框和旁边的标签是可点击的。你知道吗,我在这里做错了什么?

我已创建以下HTML代码段:

pos = pygame.mouse.get_pos()
player_image_rect.center = pos

使用以下JavaScript代码段:

<div class="ui-myProject-radio ui-myProject-fieldset clearfix">
  <input type="radio" name="prefrage1_unit" value="1" id="prefrage1_unit_id_1" data-property-name="PRE_FRAGE1_EINHEIT"/>
  <label class="prefrage1_bottom_right_in_label" for="prefrage1_unit_id_1">
    {{Str.euro_sign}}
  </label>
</div>

非常感谢:)

1 个答案:

答案 0 :(得分:1)

问题是您使用for属性label,它会触发目标元素的事件,此处是复选框。

尝试从标签中删除for属性。