Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.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 DataTables和jQuery在表中执行onclick事件_Javascript_Jquery_Datatables - Fatal编程技术网

Javascript DataTables和jQuery在表中执行onclick事件

Javascript DataTables和jQuery在表中执行onclick事件,javascript,jquery,datatables,Javascript,Jquery,Datatables,我想通过单击表中的行来执行jqueryonclick事件。问题是findjquery函数不适用于datatables <table id="GVCausal" class="table table-hover table-striped text-nowrap"> <thead> <tr> <th class="uno">@Html.CheckBox("chkAll")</th>

我想通过单击表中的行来执行jqueryonclick事件。问题是findjquery函数不适用于datatables

<table id="GVCausal" class="table table-hover table-striped text-nowrap">
    <thead>
        <tr>
            <th class="uno">@Html.CheckBox("chkAll")</th>
            <th class="uno">Código</th>
            <th>Nombre</th>
            <th class="hide">&nbsp;</th>
            <th class="uno">Indemn.</th>
            <th class="uno">Desahuc.</th>
        </tr>
    </thead>
    <tbody>
        <tr role="row" class="odd">
            <td>
                <input data-val="true" data-val-number="The field referencia must be a number." data-val-required="The referencia field is required." id="referencia" name="[0].referencia" type="hidden" value="14">
                <input id="chkDel" name="chkDel" type="checkbox" value="true"><input name="chkDel" type="hidden" value="false">
            </td>
            <td>
                <input data-val="true" data-val-number="The field id must be a number." data-val-required="The id field is required." name="[0].id" type="text" value="14">
            </td>
            <td>
                <input name="[0].nombre" type="text" value="NECESIDADES DE LA EMPRESA ,ESTA">
            </td>
            <td class="hide">Detalle de causal</td>
            <td>
                <input name="[0].indemnizac" type="text" value="S">
            </td>
            <td>
                <input name="[0].desahucio" type="text" value="S">
            </td>
        </tr>
    </tbody>
</table>


<input id="idcausal" name="idcausal" type="hidden" value="">
<textarea class="form-control" cols="20" id="detallecausal" name="detalle" onkeyup="InputChanged(this)" rows="15"></textarea>
这是我的尝试,但它不能很好地处理数据表,例如分页

<script>
    $(document).ready(function () {
        var tabla = $('#GVCausal').DataTable();
        $('#GVCausal tbody').on('click', 'tr', function () {
            var fila = tabla.row(this).data();
            $('#detallecausal').val(fila[3]);
            $('#idcausal').val(fila.find('input[name*=id]').val());
        });
    });
</script>

请使用以下代码:

$('#GVCausal tbody').on('click', 'tr', function () {
    var fila = tabla.row(this).data();
    $('#detallecausal').val(fila[3]);
    $('#idcausal').val($('input[name*=id]', this).val());
});