JQuery drop-down box app extension

Source: Internet
Author: User

An example of a jquery book

The book only writes from the left to the right, nothing more than the Remove () method and the AppendTo () method.

However, I have tried, and it is not as simple as adding from the left to the right to remove the right side to the left.

Then you can add to each other on either side.

The HTML code is as follows:

<Divclass= "equips">    <Div>        <Pclass= "Tips">You are assigning devices to users: XXX!</P>        <ahref="#"class= "BTN"ID= "Save_equip">Save</a>    </Div>    <formclass= "Equip_list"ID= "Equip_list">        <spanclass= "Show">List of optional devices:</span>        <ul>            <Li>                <inputtype= "text"name= "equips"value= "Device 1">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device 2 device 2 device 2">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device 3">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device 4">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device 5">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device 6">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device 7">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device 8">            </Li>        </ul>    </form>    <formAction= "url"Method= "POST"class= "My_equip_list"ID= "My_equip_list">        <spanclass= "Show">User Device list:</span>        <ul>            <Li>                <inputtype= "text"name= "equips"value= "Device A">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device S">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device D">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device F">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device g">            </Li>            <Li>                <inputtype= "text"name= "equips"value= "Device H">            </Li>        </ul>    </form>    <Divclass= "Btns">        <ahref="#"class= "BTN"ID= "Btn_add">Add >></a>        <ahref="#"class= "BTN"ID= "Btn_remove"><< Delete </a>    </Div></Div>

The jquery code is as follows:

$(function() {init (); //Initialize        $("#btn_add"). On ("click",function(){//Add a button to the left of the list of options, add to the right            varparam ={form_ul: $ ("#my_equip_list ul"), li_selected: $ ("#equip_list ul li.selected")} selected (param);        }); $("#btn_remove"). On ("click",function(){//Delete button to add the right border to the left border            varparam ={form_ul: $ ("#equip_list ul"), li_selected: $ ("#my_equip_list ul li.selected")} selected (param);        }); //Set the input box in a form to be read-only$ (". Equips form Input"). attr ("ReadOnly", "ReadOnly"); //Click Save to submit the user device List form$ ("#save_equip"). On ("click",function(){            $("#my_equip_list"). Form ("Submit");    })            }); functionInit () {//Binding Event Selected Add selected class        varli_s = $ (". Equips form Li"); Li_s.on ("Click",function(){            var_this = $ ( This); _this.hasclass ("Selected")? _this.removeclass ("selected"): _this.addclass ("selected"));    }); }    functionselected (param) {//a series of actions on the selected option Param.li_selected.remove (). AppendTo (Param.form_ul). Removeclass ("Selected"). On ("Click",function(){                            var_this = $ ( This); _this.hasclass ("Selected")? _this.removeclass ("selected"): _this.addclass ("selected"));    }); }

The effect is as follows:

Original:

Add some items to the right:

Selected:

Add to Left:

I feel like I'm so cute

JQuery drop-down box app extension

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.