zl程序教程

您现在的位置是:首页 >  其他

当前栏目

jQueryselect的操作实现代码

代码 实现 操作 jqueryselect
2023-06-13 09:14:09 时间
//改??r的事件
复制代码代码如下:

$("#testSelect").change(function(){//事件?生
jQuery("option:selected",this).each(function(){//印出?到多??值
alert(this.value);
});
});

//印出?到的?目
复制代码代码如下:

法1:$("select#Clubs").children("[@selected]").each(function(){
alert(this.text);
});
法2:$("#selBags").val();//???比?快啦,但限?芜x


//取得下拉??蔚倪x取值
复制代码代码如下:
$(#testSelectoption:selected").text();
或$("#testSelect").find("option:selected").text();

//移除
removeOption(index/value/regex[,selectedOnly])
复制代码代码如下:
$("select#Clubsoption:selected").remove();

//使某option???elected
复制代码代码如下:
varselect=$(tdsEdit[0]).find("select");//取得select
$(select).children().each(function(){
if($(this).text()=="optionyouwant")

//jQuery?法
复制代码代码如下:
$(this).attr("selected","true");//或是?selected也可
//javascript?法
this.selected=true;
});

?⒖?BR>http://www.texotela.co.uk/code/jquery/select/
http://blog.jeremymartin.name/2008/02/easy-multi-select-transfer-with-jquery.html