欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Jquery實(shí)現(xiàn)多選下拉列表左右移動(dòng)

 更新時(shí)間:2022年02月22日 14:35:50   作者:a遠(yuǎn)方少年  
這篇文章主要為大家詳細(xì)介紹了Jquery實(shí)現(xiàn)多選下拉列表左右移動(dòng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Jquery實(shí)現(xiàn)多選下拉列表左右移動(dòng)的具體代碼,供大家參考,具體內(nèi)容如下

jquery實(shí)現(xiàn)核心代碼

//需求:實(shí)現(xiàn)下拉列表選擇條目左右選擇功能
?? ??? ?$(function () {
?? ??? ??? ?//右移
?? ??? ??? ?$("#toRight").click(function () {
?? ??? ??? ??? ?//獲取右邊的下拉列表對(duì)象,append(左邊選中的對(duì)象)
?? ??? ??? ??? ?$("#rightName").append($("#leftName > option:selected"));
?? ??? ??? ?});
?? ??? ??? ?//左移
?? ??? ??? ?$("#toLeft").click(function () {
?? ??? ??? ??? ?$("#leftName").append($("#rightName > option:selected"));
?? ??? ??? ?});
?})
<!DOCTYPE html>
<html>
?? ?<head>
?? ??? ?<meta charset="UTF-8">
?? ??? ?<title></title>
?? ??? ?<script ?src="../../js/jquery-3.3.1.min.js"></script>


?? ??? ?<style>
?? ??? ??? ?#leftName , #btn,#rightName{
?? ??? ??? ??? ?float: left;
?? ??? ??? ??? ?width: 100px;
?? ??? ??? ??? ?height: 300px;
?? ??? ??? ?}
?? ??? ??? ?#toRight,#toLeft{
?? ??? ??? ??? ?margin-top:100px ;
?? ??? ??? ??? ?margin-left:30px;
?? ??? ??? ??? ?width: 50px;
?? ??? ??? ?}

?? ??? ??? ?.border{
?? ??? ??? ??? ?height: 500px;
?? ??? ??? ??? ?padding: 100px;
?? ??? ??? ?}
?? ??? ?</style>

?? ??? ?<script>

?? ??? ??? ?//需求:實(shí)現(xiàn)下拉列表選擇條目左右選擇功能
?? ??? ??? ?$(function () {
?? ??? ??? ??? ?//右移
?? ??? ??? ??? ?$("#toRight").click(function () {
?? ??? ??? ??? ??? ?//獲取右邊的下拉列表對(duì)象,append(左邊選中的對(duì)象)
?? ??? ??? ??? ??? ?$("#rightName").append($("#leftName > option:selected"));
?? ??? ??? ??? ?});
?? ??? ??? ??? ?//左移
?? ??? ??? ??? ?$("#toLeft").click(function () {
?? ??? ??? ??? ??? ?$("#leftName").append($("#rightName > option:selected"));
?? ??? ??? ??? ?});
?? ??? ??? ?})


?? ??? ?</script>

?? ?</head>
?? ?<body>
?? ??? ?<div class="border">
?? ??? ??? ?<select id="leftName" multiple="multiple">
?? ??? ??? ??? ?<option>張三</option>
?? ??? ??? ??? ?<option>李四</option>
?? ??? ??? ??? ?<option>王五</option>
?? ??? ??? ??? ?<option>趙六</option>
?? ??? ??? ?</select>
?? ??? ??? ?<div id="btn">
?? ??? ??? ??? ?<input type="button" id="toRight" value="-->"><br>
?? ??? ??? ??? ?<input type="button" id="toLeft" value="<--">

?? ??? ??? ?</div>

?? ??? ??? ?<select id="rightName" multiple="multiple">
?? ??? ??? ??? ?<option>錢七</option>
?? ??? ??? ?</select>

?? ??? ?</div>


?? ?</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論