javascript - How to push item values to extreme top/bottom in selectbox? -
i researching , testing forms. far, succeeded in moving items in select box list , down 1 one following fiddle.
instance of code (to move up):
function moveup() { $("#list-box option:selected").each(function () { var listitem = $(this); var listitemposition = $("#list-box option").index(listitem) + 1; if (listitemposition == 1) return false; listitem.insertbefore(listitem.prev()); }); }
but need move selected value, either @ extreme top in list or @ bottom. please try experiment fiddle , suggest me possible jquery tree traversal method if applies.
thanks in advance!
to move top:
var listitem = $(this); listitem.insertbefore(listitem.siblings().first());
to move bottom:
var listitem = $(this); listitem.insertbefore(listitem.siblings().last());
Comments
Post a Comment