Basic idea: Move Up: (1) Gets the index value of the currently selected element (2) determines whether the current element is the first element (3) If it is, then the move is not performed, if not, then the call to the InsertBefore method is inserted into his prev (adjacent to the One) element before
1 varup =function () {2 varSelectedIndex = $ ("#SelectedAddressIds option:selected"). index ();//gets the index of the currently selected element3 if(SelectedIndex >= 1){4 //Insert Previous5$ ("#SelectedAddressIds option:selected"). InsertBefore ($ ("#SelectedAddressIds option:selected"). Prev (' option '));6 }7}
Move Down: (1) Gets the index value of all option elements (2) Gets the index value of the currently selected element (3) determines whether the currently selected element is the last element, if it is, does not perform a move down, and if not, calls the InsertAfter method to insert into his Next (next to) element behind.
1 varDown =function () {2 //gets the index value of the last option3 varOptionnum = $ ("#SelectedAddressIds option"). Size ()-1;4 //gets the index value of the currently selected element5 varSelectedIndex = $ ("#SelectedAddressIds option:selected"). index ();6 7 if(SelectedIndex < 6){8 //Insert Next9$ ("#SelectedAddressIds option:selected"). InsertAfter ($ ("#SelectedAddressIds option:selected"). Next (' option '));Ten } One}
Use jquery to move up and down option