Sample Code for mutual content exchange between multiple Jquery selection boxes

Source: Internet
Author: User
Tags addall

Copy codeThe Code is as follows: <Title> No title page </title>
<Script type = "text/javascript" src = "js/jquery-1.4.2.min.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
// Append the selected item to the other party
$ ('# Add'). click (function (){
Var options = $ ('# select1 option: selected ');
Var remove = options. remove ();
Remove. appendTo ("# select2 ");
});
// Append all items to the other party
$ ('# Addall'). click (function (){
Var options = $ ('# select1 option ');
Var remove = options. remove ();
Remove. appendTo ("# select2 ");
});
// Return the selected item to the other party
$ ('# Delete'). click (function (){
Var options = $ ('# select2 option: selected ');
Var remove = options. remove ();
Remove. appendTo ("# select1 ");
});
// Return all items to the other party
$ ('# RemoveAll'). click (function (){
Var options = $ ('# select2 option ');
Var remove = options. remove ();
Remove. appendTo ("# select1 ");
});
});
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div id = "left">
<Select multiple = "multiple" id = "select1" style = "width: 100px; height: 160px">
<Option> option 1 </option>
<Option> option 2 </option>
<Option> option 3 </option>
<Option> option 4 </option>
<Option> option 5 </option>
</Select>
</Div>
<Div>
<Span id = "add"> add selected items to the right >></span> <br/>
<Span id = "addAll"> Add all to the right >></span>
</Div>
<Div id = "right">
<Select multiple = "multiple" id = "select2" style = "width: 100px; height: 160px"> </select>
</Div>
<Div>
<Span id = "remove"> <the selected item is restored to the left </span> <br/>
<Span id = "removeAll"> <restore all to the left </span>
</Div>
</Form>
</Body>

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.