分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

jQuery下拉框操作系列$("option:selected",this) ?&&(锋利的jQuery)

发布时间:2023-09-06 02:31责任编辑:沈小雨关键词:jQuery

jQuery下拉框操作系列$("option:selected",this)  &&(锋利的jQuery)

<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> ???<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> ???<title>下拉框应用</title> ???<script src="../../js/jquery-1.4.4.min.js"></script></head><body> ???<div class="centent"> ???????<select multiple id="select1" style="width:100px; height:160px;"> ???????????<option value="1">选项1</option> ???????????<option value="2">选项2</option> ???????????<option value="3">选项3</option> ???????????<option value="4">选项4</option> ???????????<option value="5">选项5</option> ???????????<option value="6">选项6</option> ???????????<option value="7">选项7</option> ???????????<option value="8">选项8</option> ???????</select> ???????<div> ???????????<span id="add">选中添加到右边≥≥</span> ???????????<span id="add_all">全部添加到右边≥≥</span> ???????</div> ???</div> ???<div class="centent"> ???????<select multiple id="select2" style="width:100px; height:160px;"></select> ???????<div> ???????????<span id="remove">选中删除到左边<<</span> ???????????<span id="remove_all">全部删除到左边<<</span> ???????</div> ???</div> ???<script> ???????$(function () { ???????????$("#add").click(function () { ???????????????var $options = $("#select1 option:selected"); ?//获取选中的选项 ???????????????//var $remove = $options.remove(); ?//删除下拉列表中选中的选项 ???????????????$options.appendTo("#select2"); ??//追加到select2 ???????????}) ???????????$("#add_all").click(function () { ???????????????var $options = $("#select1 option"); ?//获取选中的选项 ???????????????//var $remove = $options.remove(); ?//删除下拉列表中选中的选项 ???????????????$options.appendTo("#select2"); ??//追加到select2 ???????????}) ???????????$("#select1").dblclick(function () { ???????????????var $options = $("option:selected", this); ?//获取选中的选项 ???????????????//var $remove = $options.remove(); ?//删除下拉列表中选中的选项 ???????????????$options.appendTo("#select2"); ??//追加到select2 ???????????}) ???????????$("#remove").click(function () { ???????????????var $options = $("#select2 option:selected"); ?//获取选中的选项 ???????????????//var $remove = $options.remove(); ?//删除下拉列表中选中的选项 ???????????????$options.appendTo("#select1"); ??//追加到select2 ???????????}) ???????????$("#remove_all").click(function () { ???????????????var $options = $("#select2 option"); ?//获取选中的选项 ???????????????//var $remove = $options.remove(); ?//删除下拉列表中选中的选项 ???????????????$options.appendTo("#select1"); ??//追加到select2 ???????????}) ???????????$("#select2").dblclick(function () { ???????????????var $options = $("option:selected", this); ?//获取选中的选项 ???????????????//var $remove = $options.remove(); ?//删除下拉列表中选中的选项 ???????????????$options.appendTo("#select1"); ??//追加到select2 ???????????}) ???????}) ???</script></body></html>

  

jQuery下拉框操作系列$("option:selected",this) ?&&(锋利的jQuery)

原文地址:https://www.cnblogs.com/chaonuanxi/p/10336297.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved