我有一個多選框,其右邊有兩個按鈕,用於在列表中上下選擇一個選項。這工作正常,但是如果我將選項向上或向下移動到多選的頂部或底部邊界,則滾動條將不會生效並相應地移動。有什麼建議麼?在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