Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.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/0/laravel/11.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_Laravel_Checkbox - Fatal编程技术网

Javascript 单击表格旁边的表格单元格时选中表格中的复选框

Javascript 单击表格旁边的表格单元格时选中表格中的复选框,javascript,laravel,checkbox,Javascript,Laravel,Checkbox,我有一个表,其中的行如下所示:('o'是一个复选框) 这是它的代码: <table class="table table-condensed table-bordered> @foreach ($labels as $label) <tr> <td class="checkbox"><input type="checkbox" name="checkbox-one /> <td>{{ $label

我有一个表,其中的行如下所示:('o'是一个复选框)

这是它的代码:

<table class="table table-condensed table-bordered>
  @foreach ($labels as $label) 
    <tr>
      <td class="checkbox"><input type="checkbox" name="checkbox-one /> 
      <td>{{ $label }}</td>
      <td class="with-textarea"><textarea></textarea></td>
      <td class="checkbox"><input type="checkbox"  name="checkbox-two" /></td> 
    </tr>
  @foreach
</table>

{{$label}}
@弗雷奇
当用户单击左复选框或其旁边的“某个标签”时,如何实现选中左复选框

我知道我需要javascript,但我没有太多的知识。

其他类似的问题要么太老了,要么对我没有帮助。

默认情况下,单击复选框时的情况已完成。对于标签,您希望向
添加一个类:


我想没有JS你也可以这样做:


点击我
呜呜呜呜
点击我
呜呜呜呜
点击我
呜呜呜呜

那么你为什么不处理该TD的点击事件,然后使用javascript选中复选框(我相信你可以从name访问该复选框)
{{$label}
谢谢你的快速回复,我会尽快将此标记为答案让我回答。
<table class="table table-condensed table-bordered>
  @foreach ($labels as $label) 
    <tr>
      <td class="checkbox"><input type="checkbox" name="checkbox-one /> 
      <td>{{ $label }}</td>
      <td class="with-textarea"><textarea></textarea></td>
      <td class="checkbox"><input type="checkbox"  name="checkbox-two" /></td> 
    </tr>
  @foreach
</table>
<td class="mylabel">{{ label }}</td>