它只是交換了兩個(gè)select的value值,并不是交換兩個(gè)select 因?yàn)橐粋€(gè)是出發(fā)地 一個(gè)是目的地 select的option是一樣的;

創(chuàng)新互聯(lián)建站是一家專注于做網(wǎng)站、網(wǎng)站建設(shè)與策劃設(shè)計(jì),渾南網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:渾南等地區(qū)。渾南做網(wǎng)站價(jià)格咨詢:13518219792
jquery操作兩個(gè)select實(shí)現(xiàn)值之間的互相傳遞進(jìn)行了詳細(xì)的介紹,舉例:
代碼如下: function moveToRight(select1,select2)//把選中的移動(dòng)到右邊 sleect1和sleect2分別是下拉列表框的ID { $('#'+select1+' option:selected').each(function(){ $("option value='"+$(this).val()+"'"+$(this).text()+"/option").appendTo("#"+select2+""); $(this).remove(); $('#'+select2).bind('dblclick',function(){ moveToLeft(select1,select2); }); }); } function moveAllToRight(select1,select2)//把所有的移動(dòng)到右邊 { $('#'+select1+' option').each(function(){ $("option value='"+$(this).val()+"'"+$(this).text()+"/option").appendTo("#"+select2+""); $(this).remove(); }); } function moveToLeft(select1,select2)//把選中的移動(dòng)到左邊 { $('#'+select2+' option:selected').each(function(){ $("option value='"+$(this).val()+"'"+$(this).text()+"/option").appendTo("#"+select1+""); $(this).remove(); }); } function moveAllToLeft(select1,select2)//把所有的移動(dòng)到左邊 { $('#'+select2+' option').each(function(){ $("option value='"+$(this).val()+"'"+$(this).text()+"/option").appendTo("#"+select1+""); $(this).remove(); }); } 如果要雙擊select中的某一個(gè)option就把當(dāng)前值傳到另一個(gè)select需要bind一個(gè)select 事件 如下即可 代碼如下: $('#sel2').bind('dblclick',function(){//給下拉框綁定雙擊事件 moveToRight('sel2','sel3'); }); $('#sel3').bind('dblclick',function(){ moveToLeft('sel2','sel3'); });
$(function() {
//選項(xiàng)卡
$(".order_list ul li").click(function() {
$(this).addClass("on").siblings().removeClass("on"); //切換選中的按鈕高亮狀態(tài)(添加on)
var index = $(this).index(); //獲取被按下按鈕的索引值,需要注意index是從0開始的
$(".order_xxk div").eq(index).show().siblings().hide(); //在按鈕選中時(shí)在下面顯示相應(yīng)的內(nèi)容,同時(shí)隱藏不需要的框架內(nèi)容
});
});
div class='order_list'
ul
li1/li
li2/li
/ul
/div
div class="order_xxk"
div class="yige"1/div
div class="erge"2/div
/div
!DOCTYPE?html
html?lang="en"
head
meta?charset="UTF-8"
titleDocument/title
script?src="jquery-3.3.1.js"/script
style
.Tab{
}
.Tab?span{
margin-right:10px;
cursor:pointer;
}
/style
/head
body
div?class="Tab"
spanA1/span
spanB2/span
spanC3/span
/div
div?style="display:?none"?class="tab1"
div
AA1
div?style="display:?none;margin-left:?100px;"
pAAA1/p
pAAA1/p
pAAA1/p
/div
/div
div
AA2
div?style="display:?none;margin-left:?100px;"
pAAA2/p
pAAA2/p
pAAA2/p
/div
/div
div
AA3
div?style="display:?none;margin-left:?100px;"
pAAA3/p
pAAA3/p
pAAA3/p
/div
/div
/div
div?style="display:?none"?class="tab1"
div
BB1
div?style="display:?none;margin-left:?100px;"
pBBB1/p
pBBB1/p
pBBB1/p
/div
/div
div
BB2
div?style="display:?none;margin-left:?100px;"
pBBB2/p
pBBB2/p
pBBB2/p
/div
/div
div
BB3
div?style="display:?none;margin-left:?100px;"
pBBB3/p
pBBB3/p
pBBB3/p
/div
/div
/div
div?style="display:?none"?class="tab1"
div
CC1
div?style="display:?none;margin-left:?100px;"
pCCC1/p
pCCC1/p
pCCC1/p
/div
/div
div
CC2
div?style="display:?none;margin-left:?100px;"
pCCC2/p
pCCC2/p
pCCC2/p
/div
/div
div
CC3
div?style="display:?none;margin-left:?100px;"
pCCC3/p
pCCC3/p
pCCC3/p
/div
/div
/div
/body
script
$(function(){
$(".Tab?span").each(function(i){
$(this).click(function(){
$(".tab1:eq("+i+")").show().siblings(".tab1").hide()
})
})
$(".tab1div").click(function(){
$(this).find("div").show()
$(this).siblings("div").find("div").hide()
})
})
/script
/html
那是因?yàn)閠ab里面有a標(biāo)簽a href="#"文字內(nèi)容/a,當(dāng)點(diǎn)擊tab的時(shí)候也會(huì)點(diǎn)到a,應(yīng)該這樣寫:a href="javascript:void(0)"/a
或者給a加個(gè) return false 可以阻止他的默認(rèn)事件
本文實(shí)例講述了jQuery簡單tab切換效果實(shí)現(xiàn)方法。分享給大家供大家參考。具體如下:
script
src="js/jquery-latest.js"/script
SCRIPT
language=javascript
type=text/javascript
$(document).ready(function
()
{
$('.tabtitle
li').click(function
()
{
var
index
=
$(this).index();
$(this).attr('class',"tabhover").siblings('li').attr('class','taba');
$('.tabcontent').eq(index).show(200).siblings('.tabcontent').hide();
});
var
t
=
0;
var
timer
=
setInterval(function(){
if(
t
==
$('.tabtitle
li').length
)
t
=
0;
$('.tabtitle
li:eq('+t+')').click();
t++;
},
700)
})
/SCRIPT
div
class="maintab"
ul
class="tabtitle"
li
class="tabhover"a
href="#"選擇標(biāo)題1/a/li
li
class="taba"a
href="#"選擇標(biāo)題2/a/li
li
class="taba"a
href="#"選擇標(biāo)題3/a/li
li
class="taba"a
href="#"選擇標(biāo)題4/a/li
li
class="taba"a
href="#"選擇標(biāo)題5/a/li
/ul
div
class="tabcontent"
選擇內(nèi)容1
/div
div
class="tabcontent"
style="DISPLAY:
none"
選擇內(nèi)容2
/div
div
class="tabcontent"
style="DISPLAY:
none"
選擇內(nèi)容3
/div
div
class="tabcontent"
style="DISPLAY:
none"
選擇內(nèi)容4
/div
div
class="tabcontent"
style="DISPLAY:
none"
選擇內(nèi)容5
/div
/div
希望本文所述對大家的jQuery程序設(shè)計(jì)有所幫助。
!DOCTYPE
html
head
meta?http-equiv="Content-Type"?content="text/html;?charset=UTF-8"?/
style
*?{
border:?none;
margin:?0;
padding:?0;
font-size:?12px;
font-weight:?normal;
font-style:?normal;
text-align:?left;
font-family:?"宋體",?Arial,?Helvetica,?sans-serif?!important;
}
a?{
text-decoration:?none;
color:?#002244;
}
a:visited?{
color:?#5f789e;
}
a:hover?{
text-decoration:?underline;
color:?#cd0200;
}
ul,li?{
list-style-type:?none;
}
/*?正文開始*/
#mainbody?{
width:?1000px;
margin-top:?12px;
margin-right:?auto;
margin-bottom:?12px;
margin-left:?auto;
}
#mainbody?.part?{
margin-bottom:?10px;
margin-right:?10px;
width:?322px;
float:?left;
transition:?all?0.3s?ease;
-moz-transition:?all?0.3s?ease;?/*?Firefox?4?*/
-webkit-transition:?all?0.3s?ease;?/*?Safari?和?Chrome?*/
-o-transition:?all?0.3s?ease;?/*?Opera?*/
}
#mainbody?.part:hover?{
box-shadow:?2px?2px?3px?#ddd;
}
#mainbody?.part?.part-hd?{
height:?32px;
zoom:?1;
overflow:?hidden;
line-height:?32px;
}
#mainbody?.part-hd?li?{
font-size:?14px;
line-height:?30px;
width:?155px;
background:?-webkit-gradient(linear,?left?top,?left?bottom,?from(#fefefe),
to(#ededed)?);
background:?-o-linear-gradient(left?top,?left?bottom,?from(#fefefe),
to(#ededed)?);
background:?-webkit-gradient(linear,?left?top,?left?bottom,?from(#fefefe),
to(#ededed)?);
border:?1px?solid?#ddd;
float:?left;
text-align:?center;
background-color:?-webkit-gradient;
background-position:?left;
}
#mainbody?.part-hd?li.on?{
border-bottom-style:?none;
font-weight:?bold;
background-color:?#FFFFFF;
background-image:?url(yxzoo2.png);
background-repeat:?no-repeat;
background-position:?-165px?-265px;
}
#mainbody?.imgshow?{
border:?1px?solid?#ccc;
border-top:?0?none;
padding:?8px;
zoom:?1;
color:?#000000;
}
.mod-art?li?{
line-height:?25px;
height:?25px;
}
.mod-art?.date?{
float:?right;
margin-right:?5px;
}
/style
/head
script?src=""/script
script
$?(function?()
{
$?('#part-tab-con?.imgshow:nth-child(1)').show?().siblings?().hide?();
$?('.part-hd?ul?li').hover?(
function?()
{
var?me?=?$?(this);
me.addClass?('on').siblings?("li").removeClass?('on')
.closest?(".part-hd").next?("#part-tab-con")
.children?(".imgshow:eq("?+?me.index?()?+?")").show?().siblings?(".imgshow").hide?();
});
});
/script
body
div?id="mainbody"
div?class="part"
div?class="part-hd"
ul
li?class="on"玄幻奇幻/li
li武俠仙俠/li
/ul
/div
div?id="part-tab-con"
div?class="imgshow"
ul?class="mod-art"
lispan?class="date"02-16/spana?href="/1502/288021391312.html"?title="教練進(jìn)場Ban選!比賽更精彩?觀眾受益"font?color=""教練進(jìn)場Ban選!比賽更精彩
觀眾受益/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288009340360.html"?title="人家女友:國外女玩家為銳雯重鑄斷劍"font?color=""人家女友:國外女玩家為銳雯重鑄斷劍/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288007089075.html"?title="福利COS:香港正妹Bell全方位展示胸器"font?color=""福利COS:香港正妹Bell全方位展示胸器/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288010819654.html"?title="日本LJL獲外卡賽資格?季中賽或?qū)①?font?color=""日本LJL獲外卡賽資格
季中賽或?qū)①?font?/a/li
lispan?class="date"02-16/spana?href="/1502/288008186913.html"?title="網(wǎng)友盤點(diǎn):最讓人惡心的五大偷塔英雄"font?color=""網(wǎng)友盤點(diǎn):最讓人惡心的五大偷塔英雄/font
/a/li
/ul
/div
div?class="imgshow"
ul?class="mod-art"
lispan?class="date"02-16/spana?href="/1502/288007138257.html"?title="安妮情人節(jié)限定半價(jià)?其余三款正熱銷中"font?color=""安妮情人節(jié)限定半價(jià)
其余三款正熱銷中/font?/a/li
lispan?class="date"02-16/spana?href="/1502/287982376070.html"?title="每周之星:大樹好輔助Imp男槍打爆全場"font?color=""每周之星:大樹好輔助Imp男槍打爆全場/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288025318751.html"?title="2015LCS北美賽區(qū)春季賽:CLG?VS?TSM"font?color=""2015LCS北美賽區(qū)春季賽:CLG
VS?TSM/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288023188668.html"?title="杰克:牛頭努努大戰(zhàn)三百回合?竟無一傷亡"font?color=""杰克:牛頭努努大戰(zhàn)三百回合
竟無一傷亡/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288022680398.html"?title="每日精彩集錦:大魔王教你如何秀妖姬!"font?color=""每日精彩集錦:大魔王教你如何秀妖姬!/font
/a/li
/ul
/div
/div
/div
div?class="part"
div?class="part-hd"
ul
li?class="on"666/li
li5555/li
/ul
/div
div?id="part-tab-con"
div?class="imgshow"
ul?class="mod-art"
lispan?class="date"02-16/spana?href="/1502/288022168482.html"?title="LPL第五周掠影:年關(guān)將近隊(duì)員喜慶服飾"font?color=""LPL第五周掠影:年關(guān)將近隊(duì)員喜慶服飾/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288021294370.html"?title="黑子解說:嚇老子一跳?上單船長怒吼凱瑞"font?color=""黑子解說:嚇老子一跳
上單船長怒吼凱瑞/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288020471263.html"?title="Dopa盲僧我不是標(biāo)題黨?我是國服rank第一"font?color=""Dopa盲僧我不是標(biāo)題黨
我是國服rank第一/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288020025966.html"?title="ADC新年特別版:各種極限走砍?看完濕了"font?color=""ADC新年特別版:各種極限走砍
看完濕了/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288013215453.html"?title="囧鏡頭:武器死里逃生卻慘遭提莫暗算"font?color=""囧鏡頭:武器死里逃生卻慘遭提莫暗算/font
/a/li
/ul
/div
div?class="imgshow"
ul?class="mod-art"
lispan?class="date"02-16/spana?href="/1502/288013050053.html"?title="精彩瞬間:智商碾壓?卡薩丁無敵草叢戰(zhàn)"font?color=""精彩瞬間:智商碾壓
卡薩丁無敵草叢戰(zhàn)/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288011180111.html"?title="國民好輔助:上分神器錘石?我來助你超神"font?color=""國民好輔助:上分神器錘石
我來助你超神/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288010246239.html"?title="COS娛樂解說:機(jī)器人布里茨?超神輔助C"font?color=""COS娛樂解說:機(jī)器人布里茨
超神輔助C/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288009730710.html"?title="JJ辰解說:教你劍姬抗壓?讓你兩頭又如何"font?color=""JJ辰解說:教你劍姬抗壓
讓你兩頭又如何/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288009230284.html"?title="輕松一刻:這腳速?閃現(xiàn)都被嚇出來了!"font?color=""輕松一刻:這腳速
閃現(xiàn)都被嚇出來了!/font?/a/li
/ul
/div
/div
/div
div?class="part"
div?class="part-hd"
ul
li?class="on"7777/li
li武俠仙俠/li
/ul
/div
div?id="part-tab-con"
div?class="imgshow"
ul?class="mod-art"
lispan?class="date"02-16/spana?href="/1502/288021391312.html"?title="教練進(jìn)場Ban選!比賽更精彩?觀眾受益"font?color=""教練進(jìn)場Ban選!比賽更精彩
觀眾受益/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288009340360.html"?title="人家女友:國外女玩家為銳雯重鑄斷劍"font?color=""人家女友:國外女玩家為銳雯重鑄斷劍/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288007089075.html"?title="福利COS:香港正妹Bell全方位展示胸器"font?color=""福利COS:香港正妹Bell全方位展示胸器/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288010819654.html"?title="日本LJL獲外卡賽資格?季中賽或?qū)①?font?color=""日本LJL獲外卡賽資格
季中賽或?qū)①?font?/a/li
lispan?class="date"02-16/spana?href="/1502/288008186913.html"?title="網(wǎng)友盤點(diǎn):最讓人惡心的五大偷塔英雄"font?color=""網(wǎng)友盤點(diǎn):最讓人惡心的五大偷塔英雄/font
/a/li
/ul
/div
div?class="imgshow"
ul?class="mod-art"
lispan?class="date"02-16/spana?href="/1502/288008554915.html"?title="貓兒解說:青銅爬坑系列?德瑪西亞皇子"font?color=""貓兒解說:青銅爬坑系列
德瑪西亞皇子/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288008064553.html"?title="精彩集錦TOP5:殺戮銳雯萬軍叢中豪取4殺"font?color=""精彩集錦TOP5:殺戮銳雯萬軍叢中豪取4殺/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288007684920.html"?title="原涼教研室:套子VS突臉?莫甘娜專治突臉"font?color=""原涼教研室:套子VS突臉
莫甘娜專治突臉/font?/a/li
lispan?class="date"02-16/spana?href="/1502/288006698807.html"?title="土豆怪獸TOP5:原來蠻王的E可以砍死隊(duì)友"font?color=""土豆怪獸TOP5:原來蠻王的E可以砍死隊(duì)友/font
/a/li
lispan?class="date"02-16/spana?href="/1502/288006443654.html"?title="大神去哪兒:國服阿卡利14血?1V3秀翻天"font?color=""大神去哪兒:國服阿卡利14血
1V3秀翻天/font?/a/li
/ul
/div
/div
/div
/div
/body
/html
網(wǎng)頁名稱:jquery選項(xiàng)卡切換,jQuery選項(xiàng)卡
鏈接URL:http://chinadenli.net/article10/dsijpdo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、自適應(yīng)網(wǎng)站、域名注冊、營銷型網(wǎng)站建設(shè)、全網(wǎng)營銷推廣、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)