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

Source: Internet
Author: User

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

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

This article mainly introduces jquery's information about label moving up, moving down, and top-down. It is provided with examples, which are very practical. For more information, see

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:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

Var productsLabel = {

// Set the pin to top

SetHot: function (t ){

Var bar = 'showandhide _ box ';

Var obj = $ (t). parents ('.' + bar). clone (true );

$ (T). parents ('.' + bar). remove ();

$ (". ShowAndHide_list_box"). prepend (obj );

},

 

// Set up Move-up

SetUp: function (t ){

Var bar = 'showandhide _ box ';

If ($ (t). parents ('.' + barri.prev('.'{bar}.html ()! = Undefined ){

Var obj = $ (t). parents ('.' + bar). clone (true );

$ (T). parents ('.' + bar). prev (). before (obj );

$ (T). parents ('.' + bar). remove ();

} Else {

Alert ('Kiss, it's already the top one. You can't move it up again ...');

}

},

 

// Set move down

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 ('dear, it is now the bottom, and you cannot move it down ...');

}

}

}

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.