Examples of DOM operations and events in jquery Learning dropdown box Application _jquery

Source: Internet
Author: User
Today this demo is about the dropdown box.
Copy Code code as follows:

<div class= "Centent" >
<select multiple= "multiple" id= "Select1" style= "width:100px;height:160px"; >
<option value= "1" > Option 1</option>
<option value= "2" > Option 2</option>
<option value= "3" > Option 3</option>
<option value= "4" > Option 4</option>
<option value= "5" > Option 5</option>
<option value= "6" > Option 6</option>
<option value= "7" > Option 7</option>
</select>
<div>
<span id= "Add" > select Add to Right >></span>
<span id= "Add_all" > All add to Right >></span>
</div>
</div>
<div class= "Centent" >
<select multiple= "multiple" id= "Select2" style= "width:100px;height:160px"; >
<option value= "8" > Option 8</option>
</select>
</div>

The function is to add the selected option to the right, double-click an option on the left to add to the right, click on all add to the right button to add to the right to the left.
jquery Code:
Copy Code code as follows:

<script type= "Text/javascript" >
$ (function () {
$ (' #add '). Click (function () {
var $option =$ (' #select1 option:selected ');
$option. Appendto (' #select2 ');
})
$ (' #add_all '). Click (function () {
var $option =$ (' #select1 option ');
$option. Appendto (' #select2 ');
})
$ (' #select1 '). DblClick (function () {
var $option =$ (' option:selected ', this);
$option. Appendto (' #select2 ');
})
})
</script>

DblClick () is triggered when the mouse double-clicks the event.
Other methods and events before the examples are introduced, do not say.
This demo code is simple. And the function is also said to be practical.
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.