A simple jquery left and right list content switching app

Source: Internet
Author: User

Select one of the options on the left to add, you can add the selected items to the right text box, click to select All to move all options to the right, the Remove button function is the same.

HTML code:

1 <DivID= "Main">2     <DivID= "Left">3         <DivID= "Select1"class= "SEL">4             <span>Apple</span>5             <span>Huawei</span>6             <span>Htc</span>7             <span>Samsung</span>8         </Div>9         <ButtonID= "Add"value= "Check Add">Check Add</Button><BR>Ten         <ButtonID= "Add_all"value= "Check All">Select All</Button> One     </Div> A     <DivID= "Right"> -         <DivID= "Select2"class= "SEL"> -              the         </Div> -         <ButtonID= "Remove"value= "Remove add">Remove add</Button><BR> -         <ButtonID= "Remove_all"value= "Remove All">Remove all</Button> -     </Div> + </Div>

Css:

1 <style type= "Text/css" >2 . Sel{3 width:100px;4 Height:160px;5 Border:1px solid Black;6}7 span{8 Display:Block;9}Ten #left, #right{ One float: Left; A Border:1px solid Black; - Margin-right:20px; -} the . Light{ - Background-color:Blue; -} - </style>

Jquery:

1<script type= "Text/javascript" >2$ (' span '). Click (function(){3$( This). AddClass ("Light"). Siblings (). Removeclass ("Light");//When you click the Span tab, add a highlight style light to it, and remove the light attribute of the sibling tag except for the selected item;4     });5$ ("#add"). Click (function(){6         varoptions=$ ("#select1 >.light");//gets the selected item;7Options.removeclass ("Light"). AppendTo ("#select2");//Remove the Light property of the span label and move it to the right;8 9     });Ten$ ("#add_all"). Click (function(){ One         varoptions=$ ("#select1 span"); AOptions.appendto ("#select2"); -     }); -$ ("#remove"). Click (function(){ the         varoptions=$ (". Light")); -Options.removeclass ("Light"). AppendTo ("#select1"); -     }); -$ ("#remove_all"). Click (function(){ +         varoptions=$ ("#select2 span"); -Options.appendto ("#select1"); +     }); A</script>

A simple jquery left and right list content switching app

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.