How does JavaScript implement element moving effect in the composite list box? _ javascript skills

Source: Internet
Author: User
There are two listlists on the page. You need to move the elements in one ListBox to another. How can this function be implemented? The following article describes how JavaScript can achieve the element moving effect in the composite ListBox, if you are interested, study together. First, let's talk about the differences between a combo box and a list box:

The combo box includes the list box and text box functions.

Text Box: Only data can be entered

List box: Only data can be selected

Combo box: both data input and''

Application Background: There are two lists on the page. You need to move the elements of one list box to another.

   The basic idea of implementation:

(1) write the init method to initialize the two lists;

(2) Call the init method to add an onload event to the body;

(3) Write move (s1, s2) to move the options selected in s1 to s2;

(4) Write moveAll (s1, s2) to move all the options in s1 to s2.

(5) add an onclick event for the button.

The javascript code is as follows:

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.