Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.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/74.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 使用jquery单击表行时选中addclass复选框_Javascript_Jquery - Fatal编程技术网

Javascript 使用jquery单击表行时选中addclass复选框

Javascript 使用jquery单击表行时选中addclass复选框,javascript,jquery,Javascript,Jquery,我有一个表,我想选中复选框&将类添加到div当用户单击表行时,我无法让它添加类。 谁能告诉我哪里出了问题 HTML格式如下: <div class="widgit"> <table id="QR_table"> <thead> <tr class="QR_table-row"> <th class="qr_action">Checkbox</th> <th class="qr_action"

我有一个表,我想选中复选框&将类添加到div当用户单击表行时,我无法让它添加类。 谁能告诉我哪里出了问题

HTML格式如下:

<div class="widgit">
<table id="QR_table">
 <thead>
   <tr class="QR_table-row">
     <th class="qr_action">Checkbox</th>
     <th class="qr_action">Action</th>
     <th class="qr_from">FROM</th>
      <th class="qr_to">TO</th>
      <th class="qr_trans">Transport</th>
    </tr>
</thead>
<tbody>
    <tr class="QR-row">
        <td class="checkbox">
            <input class="modal-state" id="modal-1" type="checkbox" />
        </td>
        <td class="qr_action">PT</td>
        <td class="qr_from">4</td>
        <td class="qr_to">21</td>
        <td class="qr_trans">WC</td>
    </tr>
    <tr class="QR-row">
        <td class="checkbox">
            <input class="modal-state" id="modal-1" type="checkbox" />
        </td>
        <td class="qr_action">PT</td>
        <td class="qr_from">8</td>
        <td class="qr_to">2</td>
        <td class="qr_trans">T</td>
    </tr>        
</tbody>

在我看来,一切都很好

在你的小提琴里,你唯一的一个提琴是在你的桌子周围,它似乎是你试图给一个类

<div class="widgit">
<table id="QR_table">

一切正常


如果您想让它做其他事情,那么您必须更具体地说明您试图实现的目标

您的代码工作正常。。。?但它并没有用widgit类将modal open添加到div中…是的,如果你看我的示例fiddle,我将背景色添加到该类中,这样你就可以看到它被添加了。你的代码添加了该类,并且工作正常。当用户单击表行时,我尝试添加一个Refills模式,Refills代码有一个按钮,可以触发addclass,并隐藏一个复选框。谢谢,我想我是对的,它在fiddle中可以工作
<div class="widgit">
<table id="QR_table">