我有一个表,当我点击一个按钮时,我想将contenteditable设置为true,然后将焦点放在td元素上客户端看到单元格中的光标闪烁。无法集中在我的表中点击事件的元素
我似乎无法获取焦点对LicenseName电池工作。我知道'tableData'变量包含正确的元素,我在浏览器调试器中检查过它。
这是我试过的。
editLicensesDetails = function (e) {
var tableRow = $(e.target).parent().parent();
$(tableRow).css('background-color', '#dff0d8');
$(tableRow).children('[contenteditable]').attr("contenteditable", "true");
var tableData = $(tableRow).children('[contenteditable]')[0];
$(tableData).focus();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="tableLicenseDetails" style="width:100%;">
<tr>
<th>Edit</th>
<th>Delete</th>
<th>Name</th>
<th>Description</th>
<th>Product</th>
<th>Unit Of Measure</th>
<th>Variable Rate</th>
</tr>
<tr>
<td style="display:none;">@license.LicenseId</td>
<td>
<i class="fa fa-pencil" aria-hidden="true"></i>
</td>
<td>
<i class="fa fa-trash" aria-hidden="true"></i>
</td>
<td contenteditable="false">@license.LicenseName</td>
<td contenteditable="false">@license.LicenseDescription</td>
<td>@license.TradePulseProductName</td>
<td>@license.LicenseUnitOfMeasureTypeName</td>
<td>@license.IsVariableRate</td>
</tr>
</table>
? – bwyn