jquery設(shè)置select選中 jQuery實(shí)現(xiàn)select下拉框獲取當(dāng)前選中文本、值、索引?
jQuery實(shí)現(xiàn)select下拉框獲取當(dāng)前選中文本、值、索引?獲取選擇:獲取所選文本:$(“#ddlregtype”)。查找(“選項(xiàng):選中"). Text()獲取select所選的值:$(“#ddlr
jQuery實(shí)現(xiàn)select下拉框獲取當(dāng)前選中文本、值、索引?
獲取選擇:獲取所選文本:$(“#ddlregtype”)。查找(“選項(xiàng):選中"). Text()獲取select所選的值:$(“#ddlregtype”)。Val()獲取select所選的索引:$(“#ddlregtype”)。獲取(0)。Selectedindex
用js獲取select的多個(gè)選項(xiàng)值?
以下兩種方法用于獲取select:VAR obj=document.getElementByIdxX(“testselect”)來定位idvar索引=對象選擇索引選擇索引變量文本=對象選項(xiàng)[索引]。text選擇文本變量值=對象選項(xiàng)[索引]。Value在jQuery中獲取所選select值的第一種方法是$(“#testselect)選項(xiàng):選中"). Text()所選文本$(“#testselect)選項(xiàng):選中"). Val()選定值$(“#testselect”)。獲取(0)。selectedindex索引的第二種方式是$(“#tesetselect”)。查找(“選項(xiàng):選中"). Text()//selected Text.val()…….get(0).selectedIndex