Я пытаюсь установить значение для заголовка <th></th>
, где тип ввода - текст. Ниже мой jquery, который должен поставить ценность в моем th.
Вот мой формат таблицы.
<table id="tblCustomer" class="display" style="width:100%">
<thead>
<tr>
<th>
<input type="button" class="btn btn-default" value="Update" />
</th>
<th>
<input id="Import_Sequence" name="Import_Sequence" type="text" value="" />
</th>
<th>
<input id="Line" name="Line" type="text" value="" />
</th>
</tr>
<tr>
<th>
</th>
<th data-toggle="tooltip" data-container="body" data-placement="top" title="">
Import_Sequence
</th>
<th data-toggle="tooltip" data-container="body" data-placement="top" title="Line number for reference.">
Line
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Я уже пытался жестко закодировать значение в:
th.val(sequence);
Но все еще не может отобразить значение в <input id="Import_Sequence" name="Import_Sequence" type="text" value="" />
$("#tblCustomer > tbody > tr").click(function (event) {
var sequence = $(this).find("td:eq(1)").html();
var line_no = $(this).find("td:eq(2)").html();
var th = $('#tblCustomer thead tr').find("th:eq(1)");
th = th.find('input[name="Import_Sequence"]');
th.val(sequence);
});
Когда я удаляю $('#tblCustomer').DataTable({"scrollX": true});
, он работает как положено.
<script>
$(document).ready(function () {
var tblCust = $('#tblCustomer').DataTable({
"aLengthMenu": [[20, -1], [20, "All"]],
iDisplayLength: 20,
bScrollInfinite: true, //this property disables pagination
"scrollCollapse": true,
"pagingType": "simple_numbers",
"lengthChange": false,
"bInfo": false,
"dom": 'lrtip',
"scrollX": true,
"autoWidth": true
});
tblCust.columns.adjust().draw();
$("#tblCustomer > tbody > tr").click(function (event) {
var sequence = $(this).find("td:eq(1)").html();
var line_no = $(this).find("td:eq(2)").html();
var th = $('#tblCustomer thead tr').find("th:eq(1)");
th = th.find('input[name="Import_Sequence"]');
th.val(sequence);
});
});
</script>