jquery Implementation tab up, down, top
This article mainly introduces the jquery implementation of the label up, down, the top of the relevant information, and attached to the example, very practical, the need for friends can refer to the
Eg: in the background of the tag list, to achieve up, down, top function
The main implementation of the idea is the node operation, such as said: Move up, directly to the click of the item moved to the previous node, and so on, of course, the actual code implementation to add some judgments, such as the current click on the operation is already the bottom or bottom, if it is to point to the corresponding prompts, so that operators know what happened.
Ideas:
1, the first use of the Cloning method. Clone (True):
That is, the current items to be moved to save the first, ready for later use.
2, to find the current label corresponding elements and related methods:
For example:. Prev () The label above the current element
. Next () the label below the current element
Add method after () xxx
Add a method before the. before () xxx
. Prepend Add Method
3. Realize
Specific code such as:
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The |
var Productslabel = {//set top Sethot:functio N (t) {var bar = ' Showandhide_box '; var obj = $ (t). Parents ('. ') +bar). Clone (True); $ (t). Parents ('. ') +bar). Remove (); $ (". Showandhide_list_box"). prepend (obj); //Set up Setup:function (t) {var bar = ' Showandhide_box '; if ($ (t). Parents ('. ') + bar). Prev ('. ') +bar). html ()!= undefined) {var obj = $ (t). Parents ('. ') +bar). Clone (True); $ (t). Parents ('. ') +bar). Prev (). before (obj); $ (t). Parents ('. ') +bar). Remove (); }else{alert (' Pro, is now the most on the oh, can not be moved up ... ');}, //Set down Setdown:function (t) {var bar = ' Showandhide_box '; if ($ (t). Parent S ('. ') +bar). Next ('. ') +bar). html ()!= undefined) {var obj = $ (t). Parents ('. ') +bar). Clone (True); $ (t). Parents ('. ') +bar). Next () after (obj); $ (t). Parents ('. ') +bar). Remove (); }else{alert (' Pro, now is the bottom of the oh, can not be moved down ... ');} } |
The above is this article to share all the content, I hope you can enjoy.