Home >Web Front-end >HTML Tutorial >select does not support double-click dbclick event_HTML/Xhtml_web page production

select does not support double-click dbclick event_HTML/Xhtml_web page production

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:37:051916browse
XML/HTML CodeCopy content to clipboard
  1. div class="centent" style="width:200px; float:left; margin-right:20px;">    
  2. select multiple="multiple" id="select1" style="width:150px; height:160px;">    
  3. option value="1">选项1option>    
  4. option value="2">选项2option>    
  5. option value="3">选项3option>    
  6. option value="4">选项4option>    
  7. option value="5">选项5option>    
  8. select>    
  9.   
  10. div>    
  11. span id="add" style="display:block; width:140px; cursor:pointer;">选中添加到右边>>span>    
  12. span id="addAll" style="display:block; width:140px; cursor:pointer;">全部添加到右边>>span>    
  13. div>div>    
  14. div class="centent" style="width:200px; float:left; margin-right:20px;">    
  15. select multiple="multiple" id="select2" style="width:150px; height:160px;">    
  16. select>    
  17. div>    
  18. span id="add1" style="display:block; width:140px; cursor:pointer;">选中删除到左边span>    
  19. span id="addAll1" style="display:block; width:170px; cursor:pointer;">全部选中删除到左边span>    
  20. div>    
  21. div>  
JavaScript Code复制内容到剪贴板
  1. //Application of multiple selection in drop-down box 9:57
  2. $(function(){ 
  3. //Start adding the left to the right
  4. $("#add").click(function(){ //Add the selected one to the right
  5. $option = $("#select1 option:selected");
  6. $option.appendTo("#select2");
  7. })
  8. $("#addAll").click(function(){ //Add all to the right
  9. $option = $("#select1 option");
  10. $option.appendTo("#select2");
  11. })
  12. $("#select1").dbclick(function(){ //Double-click to add to the right
  13. $option = $("#select1 option:selected",this);
  14. $option.appendTo("#select2");
  15. })
  16. //Start on the right and add to the left
  17. $("#add1").click(function(){ //Add the selected item to the left
  18. $option = $("#select2 option:selected");
  19. $option.appendTo("#select1");
  20. })
  21. $("#addAll1").click(function(){ //Add all to the left
  22. $option = $("#select2 option");
  23. $option.appendTo("#select1");
  24. })
  25. $("#select2").dbclick(function(){ //Double-click to add to the left
  26. $option = $("option:selected",this);
  27. $option.appendTo("#select1");
  28. })
  29. })
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn