Jquery implements label move-up, move-down, and top-down _ jquery

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.