jQuery獲取Select選擇的Text和Value:
創(chuàng)新互聯(lián)長期為上1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為宿城企業(yè)提供專業(yè)的成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計,宿城網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。
1. var checkText=jQuery("#select_id").find("option:selected").text(); //獲取Select選擇的Text
2. var checkValue=jQuery("#select_id").val(); //獲取Select選擇的option Value
3. var checkIndex=jQuery("#select_id ").get(0).selectedIndex; //獲取Select選擇的索引值
4. var maxIndex=jQuery("#select_id option:last").attr("index"); //獲取Select最大的索引值
jQuery添加/刪除Select的Option項:
1. jQuery("#select_id").append("<option value='Value'>Text</option>"); //為Select追加一個Option(下拉項)
2. jQuery("#select_id").prepend("<option value='0'>請選擇</option>"); //為Select插入一個Option(第一個位置)
3. jQuery("#select_id option:last").remove(); //刪除Select中索引值最大Option(最后一個)
4. jQuery("#select_id option[index='0']").remove(); //刪除Select中索引值為0的Option(第一個)
5. jQuery("#select_id option[value='3']").remove(); //刪除Select中Value='3'的Option
6. jQuery("#select_id option[text='4']").remove(); //刪除Select中Text='4'的Option
內(nèi)容清空:
jQuery("#select_id").empty();
當(dāng)前名稱:jQuery添加/刪除Select的Option項:
分享URL:http://chinadenli.net/article12/gjsigc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、網(wǎng)站營銷、虛擬主機(jī)、軟件開發(fā)、網(wǎng)站策劃、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)