【发布时间】:2013-11-16 03:10:12
【问题描述】:
我有这个代码
<form method="post" class="form-horizontal" role="form">
<label for="qt" class="control-label">Qt</label>
<input type="text" class="form-control" id="qt" name="qt" min="1" step="1" />
<label for="code" class="control-label">Code</label>
<input type="text" class="form-control" id="code" name="code" placeholder="code" />
<button type="submit" class="btn btn-default">Submit</button>
操作员使用条形码扫描仪将数据插入输入字段,因此我必须创建一个 jQuery 代码,当“qt”已更改时自动关注下一个输入,并在“代码”已更改时提交表单改变了。
我读了another similar post,然后写了这个:
$(document).ready(function(){
$("#qt").change(function () {
$(this).nextAll("input").first().focus();
});
$("#code").change(function () {
this.form.submit();
});
});
但它不能正常工作。你可以试试jsfiddle.net
【问题讨论】: