<選項值="/> <選項值=">

首頁  >  文章  >  web前端  >  JQuery 對 Select option 的操作

JQuery 對 Select option 的操作

巴扎黑
巴扎黑原創
2017-06-29 10:02:401006瀏覽

下拉方塊:


##select id#=#select id#= "selectID"
 >         
選項值="1#">##1
選項>        選項值##="2">#2
#選項>        
選項值##="# 3">3
選項> #        
#選項值#=##" 4"##>4
#選項#>         選項值="5#">#5
選項>        #選項值

=

"


6

###"##### #>#####6############ #選項######>#########    ######################### ##### ###### ###### 下方是下拉方塊的基本操作:###### ###########

<script language#="javascript






##' ">        $().ready(function() { #   ## //綁定下拉方塊change事件,當下來方塊改變時呼叫 SelectChange()方法

        $("#selectID
"
).change(function() { SelectChange(); });        SelectChange() {        #//取得下拉方塊選取項目的text##屬性





。 #        var selectText #= $("#selectID#"##"option:selected
"

#).text();
        alert(selectText);
卷##//
取得下拉方塊選取項目的value屬性值
#        var selectValue ######=##### $$ (######"#######selectID######"######).val();###        alert(selectValue);###     #  alert(selectValue);###     #約##//###### 取得下拉方塊選取項目的index屬性值################        var selectIndex #######=##### $ (######"#######selectID######"######).######get#####(##### #0######).selectedIndex;###        alert(selectIndex);###        ######///######/取得下拉最大的屬性值」求出最大的屬性值」編號############        var selectMaxIndex ######=###### $(######"#######selectID ###"######).attr(#####"######index######"######);###        alert(selectMaxIndex) ;###    }######    function aa() {###        ######//##### ##
        $("#selectID").##get #(0).selectedIndex = 5;      }
    function bb() {
#        
//設定下拉方塊value屬性為4的選項  ("
#selectID
"#).val(4##);    }    function cc() {        #//為設定下拉方塊屬性為5的選項  

//
設定下拉方塊屬性為5的選項 ##         $("#selectID option[text=5]
"
).attr("selected""selected##");         $("#yyt option:contains('

5

')"

).attr(

"selected"true);

    }
    function dd() {
        
//




##1111#11


##11##111
#11 #        $("#selectID"
).app

#(
#"7"
);
    }    function ee()   }    function ee() {         //#在下拉方塊最前面新增一個選項


        $(
#        $(##"selectID
"
).prepend(#"0")
    }
    function ff() {
        
#//


##################################################################################################!選項###############        $(#######"######selectID option:last######"##########selectID option:last######"######) .remove();###    }######    function gg() {###        ######/#######移除下拉框 index屬性為1的選項############        $(######"#######selectID option[index=1]######"#######). remove();###    }######    function hh() {###         ######/### ###########        $(######"#######selectID option[value=4]######"#######).remove ();###    }###    function ii() {###        #######//######移除下拉方塊#######        $(#######"#######selectID option[text=5]#######"######).remove();# ##    }    ###    ############## ##### ####>######## ##### ######

以上是JQuery 對 Select option 的操作的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn