JQuery-js-based drop-down box

Source: Internet
Author: User
This article will share with you a piece of jQuery-based drop-down box code. If you have the same requirements, you can use it yourself. Projects often encounter drop-down boxes. Today, when flattening and responsive layout are widely used, it is very necessary to use jQuery to implement drop-down boxes, and it will also look a lot better, here we recommend a jQuery-based drop-down box code.

JQuery code:

The Code is as follows:


$ (Function (){
$ ('# Add'). click (function (){
Var $ options = $ ('# select1 option: selected ');
$ Options. appendTo ("# select2 ");
});
$ ('# Delete'). click (function (){
Var $ options = $ ('# select2 option: selected ');
$ Options. appendTo ("# select1 ");
});
$ ('# Add_all'). click (function (){
Var $ options = $ ('# select1 option ');
$ Options. appendTo ("# select2 ");
});
$ ('# Remove_all'). click (function (){
Var $ options = $ ('# select2 option ');
$ Options. appendTo ("# select1 ");
});
$ ('# Select1'). dblclick (function (){
Var $ options = $ ("option: selected", this); // obtain the selected option
$ Options. appendTo ('# select2 ');
});
$ ('# Select2'). dblclick (function (){
Var $ options = $ ("option: selected", this); // obtain the selected option
$ Options. appendTo ('# select1 ');
});
});

HTML code:

The Code is as follows:




Option 1 Option 2 Option 3 Option 4 Option 5 Option 6 Option 7 Option 8


Select Add to right>

Add all to the right>






< <选中删除到左边

< <全部删除到左边




Is it easy? If necessary, you can use the tool in the project.

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.