This article mainly introduces jquery's information about label moving up, moving down, and top-down, and attaches an example. It is very practical. If you need it, refer to eg: for example, in the tag list in the background, the options include move up, move down, and top down.
The main implementation idea is node operations, such as moving up, directly moving the click item to the previous node, and so on. Of course, some judgment should be added to the actual code implementation, for example, if the current click operation item is set to a bottom or a base, a prompt is provided to let the operator know what has happened.
Ideas:
1. clone (true ):
That is, the items to be moved are saved first and used later.
2. Find the related elements corresponding to the current tag and their related methods:
For example:. prev () labels on the current element
. Next () Labels under the current element
Add a method after. after () xxx
Add method before. before () xxx
. Prepend add Method
3. Implementation
The specific code is as follows:
Var productsLabel = {// setHot: function (t) {var bar = 'showandhide _ box'; var obj = $ (t ). parents ('. '+ bar ). clone (true); $ (t ). parents ('. '+ bar ). remove (); $ (". showAndHide_list_box "). prepend (obj) ;}, // you can move setUp up: function (t) {var bar = 'showandhide _ box'; if ($ (t ). parents ('. '+ barri.prev('.'your barri.html ()! = Undefined) {var obj = $ (t ). parents ('. '+ bar ). clone (true); $ (t ). parents ('. '+ bar ). prev (). before (obj); $ (t ). parents ('. '+ bar ). remove ();} else {alert... ') ;}}, // setDown: function (t) {var bar = 'showandhide _ box'; if({(t}.parents('.'{bar}.next('.'{bar}.html ()! = Undefined) {var obj = $ (t ). parents ('. '+ bar ). clone (true); $ (t ). parents ('. '+ bar ). next (). after (obj); $ (t ). parents ('. '+ bar ). remove ();} else {alert... ');}}}
The above is all the content shared in this article. I hope you will like it.