【发布时间】:2018-03-07 06:33:18
【问题描述】:
我想做的事!!
我在页面上有一个文本框,页面加载焦点将设置到文本框中,我将扫描一项并将其数字插入文本框。基于值,它将在 html 中添加一行表。同时我想将焦点放在“CODE”单元格文本框上。
因此,每次我扫描某些内容时,它都会在下表中插入一行,并且每次我想将焦点设置在最后一行的 CODE 列的单元格上。在代码列中,我们将扫描该值并将其显示在同一个单元格。
如果可能的话,我想在扫描代码单元值中的值后将焦点设置回文本框。所以基本上是它的来回扫描过程。
<input type="text" name=" " value=" ">
<br>
<div class="t-Report-tableWrap">
<table class="t-Report-report" summary="Text Test">
<thead>
<tr>
<th class="t-Report-colHead" align="center" id="DERIVED$01" > </th>
<th class="t-Report-colHead" align="center" id="C003" >Id</th>
<th class="t-Report-colHead" align="center" id="C001" >Name</th>
<th class="t-Report-colHead" align="center" id="C002" >Code</th>
<th class="t-Report-colHead" align="center" id="C007" >Text</th>
</tr>
</thead>
<tbody>
<tr id="init_row_invoice" style="display:none;" >
<td class="t-Report-cell" headers="DERIVED$01">
<a href ="javascript:void();" class="fa fa-trash-o"></a>
</td>
<td class="t-Report-cell" headers="C003">(null)</td>
<td class="t-Report-cell" headers="C001">(null)</td>
<td class="t-Report-cell" headers="C002">
<label for="f02_0000" id="f02_0000_LABEL" class="u-VisuallyHidden"></label>
<input type="text" name="f02" size="15" maxlength="2000" value="" class="u-TF-item u-TF-item--text" id="f02_0000" />
</td>
<td class="t-Report-cell" headers="C007">
<label for="f03_0000" id="f03_0000_LABEL" class="u-VisuallyHidden"></label>
<input type="text" name="f03" size="15" maxlength="2000" value="" class="u-TF-item u-TF-item--text" id="f03_0000" />
<input type="hidden" name="f01" value="" class="u-TF-item u-TF-item--hidden" id="f01_0000" />
<input type="hidden" name="f04" value="" class="u-TF-item u-TF-item--hidden" id="f04_0000" />
<input type="hidden" id="fcs_0000" name="fcs" value="">
<input type="hidden" id="fcud_0000" name="fcud" value="D" />
</td>
</tr>
<tr>
<td class="t-Report-cell" headers="DERIVED$01">
<a href ="javascript:void(1);" class="fa fa-trash-o"></a>
</td>
<td class="t-Report-cell" headers="C003">90001</td>
<td class="t-Report-cell" headers="C001">Samsung Galaxy J3 Pro</td>
<td class="t-Report-cell" headers="C002">
<label for="f02_0001" id="f02_0001_LABEL" class="u-VisuallyHidden"></label>
<input type="text" name="f02" size="15" maxlength="2000" value="123456" class="u-TF-item u-TF-item--text" id="f02_0001" />
</td>
<td class="t-Report-cell" headers="C007">
<label for="f03_0001" id="f03_0001_LABEL" class="u-VisuallyHidden"></label>
<input type="text" name="f03" size="15" maxlength="2000" value="1" class="u-TF-item u-TF-item--text" id="f03_0001" />
<input type="hidden" name="f01" value="" class="u-TF-item u-TF-item--hidden" id="f01_0001" />
<input type="hidden" name="f04" value="1" class="u-TF-item u-TF-item--hidden" id="f04_0001" />
<input type="hidden" id="fcs_0001" name="fcs" value="9F677BEDD6F6624C586A9DA8BB60AA3DC1746ED2">
<input type="hidden" id="fcud_0001" name="fcud" value="U" />
</td>
</tr>
</tbody>
</table>
</div>
<div class="t-Report-links"></div>
<table class="t-Report-pagination t-Report-pagination--bottom" role="presentation">
<tr>
<td colspan="9" align="right" >
<table role="presentation" >
<tr>
<td class="pagination"></td>
<td class="pagination"></td>
<td nowrap="nowrap" class="pagination">
<span class="t-Report-paginationText">1 - 3</span>
</td>
<td class="pagination"></td>
<td class="pagination"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
为了更清楚。
从贴纸中扫描值,它会将值插入文本框,现在它会在表格中添加一个 rwo,同时它将再次将焦点设置到最后一行的单元格列 CODE 我们将从贴纸中扫描值,扫描后它应该将焦点设置回文本框。
【问题讨论】:
-
@HemaNandagopal 我卡在设置焦点上。我可以追加行。
-
在添加时您是否尝试过 $('#C002').focus(); ?
-
C002 是 th 和表格单元格它是 f02_0001 所以我试过这个 $('#f02_0001 ').focus();因为我想专注于细胞但没有运气
-
$("'#f02_0001 输入").focus();将焦点设置为输入怎么样?
标签: javascript jquery html css