Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/394.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
条件表达式中的JavaScript标记类型,如果_Javascript_Jquery - Fatal编程技术网

条件表达式中的JavaScript标记类型,如果

条件表达式中的JavaScript标记类型,如果,javascript,jquery,Javascript,Jquery,我不明白为什么单击按钮后,if中的条件为true。在以下情况下,我预计单击上述按钮不会执行指令: $('.table tbody tr')。单击(函数(事件){ if(event.target.type!=“单选”&&event.target.type!=“按钮”){ $(':radio',this).trigger('click'); $(“tr”).removeClass(“当前默认值”); $(this.addClass(“curr_default”); } }); {currs%中的

我不明白为什么单击
按钮后,
if
中的条件为
true
。在以下情况下,我预计单击上述按钮不会执行指令:

$('.table tbody tr')。单击(函数(事件){
if(event.target.type!=“单选”&&event.target.type!=“按钮”){
$(':radio',this).trigger('click');
$(“tr”).removeClass(“当前默认值”);
$(this.addClass(“curr_default”);
}
});

{currs%中的curr为%s}
{{loop.index}}
{{curr.abbr}}
{{curr.name}
{%endfor%}

单击
按钮时,您很可能会点击
按钮内的
span
,然后在
侦听器中单击
事件.target.type
将是
未定义的


因此,要么重新修改条件以覆盖其他元素,要么可以使用
指针事件:无按钮时,点击将点击
按钮而不是
span
而不是
。您很可能会点击
按钮内的
span
,在
点击
侦听器中,
事件。target.type
将是
未定义的

因此,要么重新修改条件以覆盖其他元素,要么可以使用
指针事件:无span
上使用code>(CSS),因此单击将点击
按钮而不是
span

<table>
  <tbody>
    {% for curr in currs %}
    <tr class="{% if curr.default == curr.abbr %}curr_default{% endif %}">
      <th scope="row">{{ loop.index }}
        <span class="radio">
          <input type="radio" name="curr_default" />
        </span>
      </th>
      <td>{{ curr.abbr }}</td>
      <td>{{ curr.name }}</td>
      <td>
        <button id="{{ curr.id }}" onClick="get_currID(this.id)" type="button" class="btn p-0 w-auto"
          data-toggle="modal" data-target="#deleteCurrency">
          <span class="fa fa-trash text-danger"></span>
        </button>
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>