我有一个多选框,其右边有两个按钮,用于在列表中上下选择一个选项。这工作正常,但是如果我将选项向上或向下移动到多选的顶部或底部边界,则滚动条将不会生效并相应地移动。有什么建议么?在MultiSelect中排序选项时,滚动条不会移动
的JavaScript:
$(document).ready(function() {
$("#mup")[0].attachEvent("onclick", moveUpItem);
$("#mdown")[0].attachEvent("onclick", moveDownItem);
});
function moveUpItem() {
$('#list option:selected').each(function() {
$(this).insertBefore($(this).prev());
});
}
function moveDownItem() {
$('#list option:selected').each(function() {
$(this).insertAfter($(this).next());
});
}
//Holding down the Up/Down buttons
$(document).ready(function() {
var timer;
$("#mup, #mdown").on('mousedown', function() {
if (this.id === 'mup') {
timer = setInterval(moveUpItem, 250);
} else {
timer = setInterval(moveDownItem, 250);
}
}).on('mouseup', function() {
clearInterval(timer);
});
});
$(document).ready(function() {
$("#submit").click(function() {
$("#list").each(function() {
$("#list option").attr("selected","selected");
});
$("#detColumnSortorder").submit;
});
});
HTML:
<table>
<tr>
<td align="center">
<select id="list" name="fieldNames" size="15" multiple="multiple" style="width: 250px;">
<c:forEach var="field" items="${detFields}">
<option value="${field.fieldName}">${field.displayName}</option>
</c:forEach>
</select>
</td>
<td>
<button id="mup">
<img src="../images/button_up.gif" alt="Hold to move up faster."/>
</button>
</td>
<td>
<button id="mdown">
<img src="../images/button_down.gif" alt="Hold to move down faster."/>
</button>
</td>
</tr>
<tr>
<td style="text-align: center;">
<input name="action" id="submit" type="submit" value="Submit"/>
<input name="action" type="submit" value="Cancel"/>
</td>
</tr>
</table>
我想选择滚动条不能访问 – 2012-03-21 19:43:21