jquery implementation tab up, down, top

Source: Internet
Author: User
Tags prev

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.


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.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.