Javascript 我在表格中有一组文本框,我想通过按shift+选择多个文本框值;向下箭头。
我在表格中有一组文本框,我想通过按shift+向下箭头键选择多个文本框值。 选择文本框时,应将值复制并存储在数组中。。。 请有人帮帮我Javascript 我在表格中有一组文本框,我想通过按shift+选择多个文本框值;向下箭头。,javascript,jquery,html,Javascript,Jquery,Html,我在表格中有一组文本框,我想通过按shift+向下箭头键选择多个文本框值。 选择文本框时,应将值复制并存储在数组中。。。 请有人帮帮我 <style> #feedback { font-size: 1.4em; } #selectable .ui-selecting { background: #FECA40; } #selectable .ui-selected { background: #F39814; color: white; } #selectable {
<style>
#feedback { font-size: 1.4em; }
#selectable .ui-selecting { background: #FECA40; }
#selectable .ui-selected { background: #F39814; color: white; }
#selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
#selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
</style>
<script>
$(function(e) {
$( "#selectable" ).selectable({selected: function( event, ui ) {alert(this)}});
});
</script>
<body>
<table width="78%" border=1 id="selectable" style="border-collapse:collapse">
<tr>
<td><input type="text" class="ui-widget-content" /></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
</tr>
<tr>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
</tr>
<tr>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
</tr>
<tr>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
<td><input type="text" class="ui-widget-content"/></td>
</tr>
</table>
</body>
</html>
#反馈{字体大小:1.4em;}
#可选。用户界面选择{背景:#FECA40;}
#可选。ui已选择{背景:#F39814;颜色:白色;}
#可选{列表样式类型:无;边距:0;填充:0;宽度:60%;}
#可选li{边距:3px;填充:0.4em;字体大小:1.4em;高度:18px;}
$(功能(e){
$(“#可选”).selectable({selected:function(event,ui){alert(this)}});
});
使用jquery
你可以用
$("your id").keypress(function(e){
//here you find e.KeyCode if it is equal to shift+down_arrow then take the values of text box here as $("#yout text box id").val(); and store it into an array.
});
根据问题:
请参见这里有一段代码,可以让您选中未选中的框并获取这些框的值(使用Shift+上/下箭头) 此处的完整工作代码=> 你可以稍微调整一下,使它适合你的需要
$(function () {
var keys = {}, // Keys strokes state
storage = {}; // Tracking of checked checkboxes values
$(document).keydown(function (e) {
// UPDATE Keys strokes state to memorize simultaneous keydown ...
// THEN update values storage
}).keyup(function (e) {
// UPDATE Keys strokes to remove released keys
}).click(function(e){
// UPDATE values storage in case a checkbox get clicked ...
});
});
该功能不是“标准”功能,所以我不推荐它,因为它会在使用其他应用程序时混淆用户,因为shift+down通常与一个范围相关联。为什么不做一些直观的事情,比如在输入框旁边放一个复选框。
$(function () {
var keys = {}, // Keys strokes state
storage = {}; // Tracking of checked checkboxes values
$(document).keydown(function (e) {
// UPDATE Keys strokes state to memorize simultaneous keydown ...
// THEN update values storage
}).keyup(function (e) {
// UPDATE Keys strokes to remove released keys
}).click(function(e){
// UPDATE values storage in case a checkbox get clicked ...
});
});